<p>外部调用JS弹出窗口<br /> <br /> 但搜索了都没有直接的,都是Javascript的代码,都不是外部调用的<br /> 以下是整个制作思路和代码<br /> <br /> 先把现有的Javascript代码转换成JS文件<br /> Javascript代码:<br /> <script language="JavaScript"> <br /> <!-- <br /> var gt = unescape('%3e'); <br /> var popup = null; <br /> var over = "Launch Pop-up Navigator"; <br /> popup = window.open('', 'popupnav', 'width=200,height=170,resizable=1,scrollbars=auto'); <br /> if (popup != null) { <br /> if (popup.opener == null) { <br /> popup.opener = self; <br /> } <br /> popup.location.href = "1.html" <br /> } <br /> // --> <br /> </script><br /> <br /> 转换完为:<br /> document.writeln(&quot;<script language="JavaScript">"); <br /> document.writeln(""); <br /> document.writeln("<!--"); <br /> document.writeln(""); <br /> document.writeln("var gt = unescape('%3e');"); <br /> document.writeln(""); <br /> document.writeln("var popup = null;"); <br /> document.writeln(""); <br /> document.writeln("var over = "Launch Pop-up Navigator";"); <br /> document.writeln(""); <br /> document.writeln("popup = window.open('', 'popupnav', 'width=200,height=170,resizable=1,scrollbars=auto');"); <br /> document.writeln(""); <br /> document.writeln("if (popup != null) {"); <br /> document.writeln(""); <br /> document.writeln("if (popup.opener == null) {"); <br /> document.writeln(""); <br /> document.writeln("popup.opener = self;"); <br /> document.writeln(""); <br /> document.writeln("}"); <br /> document.writeln(""); <br /> document.writeln("popup.location.href = "1.html""); <br /> document.writeln(""); <br /> document.writeln("}"); <br /> document.writeln(""); <br /> document.writeln("// -->"); <br /> document.writeln(""); <br /> document.writeln("</script>&quot;);<br /> <br /> 把转换完的代码保存成1.js<br /> 注:document.writeln(&quot;popup.location.href = &quot;1.html&quot;&quot;); 的意思就是弹出1.html文件<br /> 接着我们新建一个1.html<br /> <br /> 在里面添加弹出窗口的内容并保存。<br /> 最后一步就是制做首页index.html<br /> 新建一个index.html文件<br /> <br /> 在</p> <p>之间加入<script src="1.js" type="text/javascript"></script><br /> <br /> 保存index.html文件<br /> 最后运行index.html<br /> 总结:index.html文件外部调用1.js 通过1.js实现弹出窗口1.html</p>
返回顶部 留言