[thelist] Opening New Web Page in the Same Window Using

Keith cache at dowebs.com
Sat Dec 15 17:27:17 CST 2001


Syed 

> Thank you for helping, but I already know that you told me. According
> to my deficient information, window.location="" method does not help
> to pass the variables from one web page to another 

Yup, you got "deficient information" alright if you're trying to pass 
"variables", it's easy to pass variables from one web page to 
another with window.location, you just parse a query string to the 
location. There are examples below. 

But I'm guessing that you are really hoping to pass "attributes" so 
you can change the browser's chrome (hence the use of 
window.open). Lot'saluck, AFAIK that can only be done in NN4+. 
Documentation says NN needs a signed script but you can trick it. 
The following removes all chrome and resizes the current Netscape 
window while loading some.html in the current browser window

<script>
self.name="WIN"
window.open("some.html","WIN","scrollbars=0,width=500,height=5
00")
</script>

But it only works w/NN. Window attributes do not belong to IE's 
window object, IE loads some.html in the same window but does 
not remove the chrome or resize it.

Here's 3 location ways to pass "variables" to another page in the 
same window if that's what you want to do

=================
<html><head>
<script>
var one="abc"
var two="xyz"
function send(){
window.location="some.html?one="+one+"&two="+two
}
</script></head>
<body>
<a href=javascript:send()>Send</a>
</body>
===============
===============
<html><head>
<script>
function send(Form){
window.location="some.html?one="+Form.one.value+"&two="+For
m.two.value
}
</script></head>
<body>
<form>
<input name=one value="abc">
<input name=two value="xyz">
<input type=buttton value=Send onclick=send(this)>
</form>
</body>
===============

You can accomplish the same form passing without javascript using 
a GET submission
===============
<html>
<body>
<form method=get action="some.html">
<input name=one value="abc">
<input name=two value="xyz">
<input type=submit value=Send>
</form>
</body>
===============

All three of the above will load some.html into the same window with 
the url
some.html?one=abc&two=xyz

To use the query string

<script>
vars=new Array();pair=new Array()
qs=location.search.substring(1)
vars=qs.split("&")
for(i=0;i<vars.length;++i){
pair=vars[i].split("=")
document.write(pair[1])
}
</script>


keith




More information about the thelist mailing list