...

View Full Version : opening windows with javascript and passing it variables



aasimajaz
07-13-2003, 02:47 AM
// this is what i am tring to use. the document "."write gives out proper query string, but the window.open only gives upto "?" n nathing after it.

function openWin(url,ref)
{
x=(url+'?'+ref);
document.write(x);
window.open(x);
}


<a href="javascript:openWin('email.php','ref=aasim')">this page</a>


any idea about it

thanks

Mr J
07-13-2003, 02:20 PM
Something like this maybe?


In the calling document.

<script language="JavaScript">
<!--
function passdata(url,data) {
var str=data
window.open(url + '?' + escape(str),'win1','left=300,top=100,width=300,height=300')
}
//-->
</script>
<a href="#null" onclick="passdata('page2.htm','Hello World')">Pass Data</a>

In the called document. (page2.htm)

<script language="JavaScript">
<!--
var dataPassed = '';
if (location.search.length > 0)
dataPassed = unescape(location.search.substring(1));
document.write(dataPassed);
//-->
</script>

cheesebagpipe
07-13-2003, 09:34 PM
Try losing the document.write(x); statement, which should never be called on a loaded document (page).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum