...

View Full Version : popup to internal code in same file?



unknown00
07-08-2011, 03:20 PM
so i have code to make a popup via javascript and it works fine, but what actually pops up is an external file that i select (in my case test.html). i want all of the code of test.html to be in my index.html and when i call the popup it doesn't call an external file but instead calls the html code in the internal file (index.html)? possible?



<head>
<script language="javascript" type="text/javascript">
function popitup(url) {
newwindow=window.open(url,'name','status = 0,resizable = 0,height=500,width=600');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
</head>
<body>
<a href="test.html" onclick="return popitup('test.html')">About</a>
</body>

what's in test.html? it's a form
why? i need the code of test.html to access some global javascript variables in index.html

tfburges
07-08-2011, 08:03 PM
If you need to access js variables in both the form and the original page, instead of popping up a brand new window with the form, popup a fixed div on top of the original page. As far as I know, there's no quick and easy way (of which is cross-browser compatible) to share javascript across separate windows.

I'll whip up something real quick that should work for you.


<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style type="text/css">
#test {
display:none;
position:fixed;
height:300px;
width:360px;
top:100px;
left:50%;
margin-left:-200px;
padding:20px;
background:#ff0000;
text-align:center;
z-index:999;
}
a {
cursor:pointer;
cursor:hand;
}
</style>
<script language="javascript" type="text/javascript">
function Show(id) {
document.getElementById(id).style.display = 'block';
}
</script>
</head>
<body>
<div id="test">
<h1>Here's your form</h1>
<form method="post">
<input type="text" name="Etc">
<input type="submit" name="Submit" value="Submit">
</form>
</div>
<a onclick="Show('test');">About</a>
</body>
</html>

sunfighter
07-08-2011, 08:03 PM
tfburges got there first..



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum