javascript 如何制作弹窗广告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12525510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:26:18  来源:igfitidea点击:

how to make a pop up window advertisement

javascripthtmlpopup

提问by user1679212

wondering how to pop up window advertisements works and how to make them. So while visitors will visit a website it will automatically open a page in a new pop windows for the first click.. I am really keen to learn this. Thanks

想知道如何弹出窗口广告的工作原理以及如何制作它们。因此,当访问者访问一个网站时,它会在第一次点击时自动在新的弹出窗口中打开一个页面。我真的很想了解这一点。谢谢

回答by Michael

Try this

试试这个

<script>
window.open('http://www.yourdomain.com/yourad.html','popupad','width=200,height=150')
</script>

or

或者

For Internet Explorer

对于 Internet Explorer

I mage pop up

我法师弹出

<script>

var newPopup=window.open("","PopupWindow","height=250,width=250");
var popContent='<HTML><HEAD><TITLE>GetSmart</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>';
popContent+= '<a target="_blank" href="http://DomainURL"><img src="http://www.yourdomain.com/ads/yourimage.gif" height=250 width=250 border=0></a>';
popContent+='</BODY></HTML>';
newPopup.document.write(popContent);
newPopup.document.close();
newPopup.focus();
</script>

OR

或者

Code for Netscape

网景代码

<script>
var newPopup=window.open("","PopupWindow","height=250,width=250");
var popContent='<HTML><HEAD><TITLE>GetSmart</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>';
popContent+= '<a target="_blank" href="http://DomainURL"><img src="http://www.yourdomain.com/ads/yourimage.gif" height=250 width=250 border=0></a>';
popContent+='</BODY></HTML>';
newPopup.document.write(popContent);
newPopup.document.close();
newPopup.focus();
</script>

回答by skunkfrukt

You can open a new window using the window.open(URL)JavaScript method, but there is no guarantee that the user will allow it. That's what popup blockers are for.

您可以使用window.open(URL)JavaScript 方法打开一个新窗口,但不能保证用户会允许它。这就是弹出窗口阻止程序的用途。

EDIT:W3Schools have some more information on the Window open() Method.

编辑:W3Schools 有一些关于Window open() Method 的更多信息。

回答by Marko Vranjkovic

You can do it with something like this:

你可以这样做:

<body onload="window.showModalDialog('http://www.google.com');">

After page load, user will have option to allow or block pop-up window

页面加载后,用户可以选择允许或阻止弹出窗口