js--- 붙여넣기판,iframe 작업

5251 단어 htmlXHTML
최근에 사용한 두 가지 물건
복사하여 붙여넣기:

<script language="javascript"> 
function readTxt(){ 
	alert(window.clipboardData.getData("text")); 
} 

function setTxt(){ 
	var t=document.getElementById("txt"); 
	t.select();
	window.clipboardData.setData('text',t.value); 
} 
</script> 
<input name="txt" value=" "> 
<input type="button" value=" " onclick="setTxt()"> 
<input type="button" value=" " onclick="readTxt()">


iframe 작업:
aa.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
<style type="text/css">
<!--
body{
margin:0px;
}
-->
</style>
</head>
<body>
<iframe id="ifr" name="ifr" width="100%" height="500" src="bb.htm"></iframe>
</body>
</html>
<script language="javascript" type="text/javascript">

var aa_value="I'm a variant in Top window!";

var ifr_id=document.getElementById("ifr");
var ifr_window=window.frames["ifr"];

alert("Alert from Top window : Can't get iframe's variant by ifr_id, it will return :" + ifr_id.bb_var);
alert("Alert from Top window : Can't get iframe's DOM model by ifr_id ,it will return :" + ifr_id.window);
alert("Alert from Top window : Get src from id :" + ifr_id.src);
alert("Alert from Top window : Get href from window:" + ifr_window.document.location.href);

// bb.htm , ,  
// iframe  ifr_window.bb();

// iframe 
alert("Alert from Top window : " + ifr_window.bb_var);

//
alert("Alert from Top Window :" + ifr_window.document.body.innerHTML);


function aa(msg){
    alert("I'm  alerting from Top window ,and I received a msg:
" + msg); } </script>

bb.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>sub frame</title>
<style type="text/css">
<!--
html,body{
margin:0px;
width:90%;
}
-->
</style>
</head>
<body>
    I'm a sub frame!
    <br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...<br />
    ...
</body>
</html>
<script language="javascript" type="text/javascript">

var bb_var="I'm a  variable in ifr";
/**/
function bb(){
    alert("Alert from iframe :I'm frame ifr's function")
}

// 
alert("Alert from iframe parent.ifr_id::" + parent.ifr_id);
alert("Alert from iframe parent.aa_value : " + parent.aa_value);

// ifr_id  iframe 
alert("Alert from iframe : ifr's clientHeight :" +document.body.clientHeight);
parent.ifr_id.height=document.body.clientHeight;

alert("Alert from iframe : ifr's scrollHeight : " + document.body.scrollHeight);

// :
parent.aa("I will calling a function which is Top window's ");

// :
alert("Alert from iframe : I will changing Top window's title");
top.document.title="The title value changed";

// ifr_id border  scrolling
alert("Alert from iframe : I will change my border and scrolling :");
top.ifr_id.border=0;
top.ifr_id.scrolling="no";
</script>

좋은 웹페이지 즐겨찾기