Forum Moderators: open
I need to transform my no-frame page into a framed page by clicking a link/button, no popups, other page spawning.
Here is my test code, that apparently doesn't work, all remains blank.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<title>test</title>
<script type="text/javascript" language="javascript">
//<![CDATA[
$(document).ready(function() {$("a").click(function() {
$("body").replaceWith(
'<frameset rows="17,*" framespacing="0" >'+
'<frame name="topframe" src="http://www.example.org" marginwidth="0" marginheight="0" noresize scrolling="no" frameborder="0">'+
'<frame name="bottomframe" src="http://www.example.org" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0">'+
'</frameset>'
);
return false;
});
});
//]]>
</script>
</head>
<body>
<a href="#">click</a>
</body>
</html>
When I click the "click" link, body should be replace by the html frames code. I think it occurs because the link disappears, but it doesn't get replaced by the two frames I've just created. No errors/warnings show in the console.
Any idea? Thank you.
$(document).ready(function() {
$("a").click(function() {
var fs = document.createElement('frameset'),
f1 = document.createElement('frame'),
f2 = document.createElement('frame');
fs.rows = "17,*";
fs.framespacing = "0";
f1.name = "topframe";
f1.src = "http://www.example.org";
f1.marginwidth = "0";
f1.marginheight = "0";
f1.noresize = "noresize";
f1.scrolling = "no";
f2.name = "bottomframe";
f2.src = "http://www.example.org";
f2.marginwidth = "0";
f2.marginheight = "0";
f2.scrolling = "auto";
f2.frameborder = "0";
fs.appendChild(f1);
fs.appendChild(f2);
$("body").replaceWith(fs);
return false;
});
});