Javascript打开新窗口并设置简单界面

有时间的话,每天写一点儿代码,不然真的会生疏的。

最近突然开始学习javascript,新手,绝对的新手,希望老手也多多指教。我就稍微的记录一下,这几天学习的效果和成果的展示。

note:非专业文章,没有参考性。。。

今天用javascript实现的打开新窗口。好的:

贴代码:

<html>
<head>
	<title>new document test</title>
</head>
<body>
	<h1>open a new window </h1>
	<input type="button" οnclick="openNewWindow()" value="open a new window"></input>
	<script type="text/javascript">
		var newWindow = null;
		function openNewWindow(){
                        //open a new window by using window.open();
                        newWindow = window.open("","","width=700,height=400");
			newWindow.focus();
		};
	</script>
</body>
</html>
window.open可以在当前的窗口下面直接打开一个窗口。

open()总共有三个参数,第一个是窗口的url就是你要打开到什么地方,第二个是窗口的名字,这个随便了,第三个主要是一些样式,像我就定义了一些窗口的大小,这个是一个空的窗口,什么也没有,可以在第一个参数填入"http://www.baidu.com",这样就可以打开百度的界面了。

第二是:

<html>
<head>
	<title>new document test</title>
</head>
<body>
	<h1>open a new window </h1>
	<input type="button" οnclick="openNewWindow()" value="open a new window"></input>
	<script type="text/javascript">
		var newWindow = null;
		function openNewWindow(){
			//open a new window by using window.open();
			newWindow = window.open("","","width=700,height=400");
			newWindow.focus();
                        //下面的代码可以设置窗口的内容哦!!!其实就是一个HTML字符串,通过document.wirte(),写入进去的!
			var strContent = "<html><body><bdo dir='rtl'>here is your text</bdo>"+
			"<p>you have some <del>little</del> <ins>big dicks</ins><p></body></html>";
			newWindow.document.write(strContent);
			newWindow.document.close();
		};
	</script>
</body>
</html>
这个是什么效果,大家打开看一下吧。。。
刚刚学习,就出来卖弄,找死哦!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值