[advanced search]
32 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Webmaster Tutorials
User Name
Password

Old 08-09-2003, 05:28 AM   · #1
Mp)Tarh
....what?
 
Mp)Tarh's Avatar
 
Location: Ontario, Canada
Trader Rating: (0)
Join Date: Aug 2003
Posts: 101
NP$: 171.00 (Donate)
Mp)Tarh is an unknown quantity at this point
Howto: Change Variables Between Windows With JavaScript

Have you always wanted to communicate between windows like the parent and child and change variables or other unchangable material? Well today is your lucky day!

Just recently, while designing my latest site, I came up with a way to comunicate whatever you want between windows without using build in javascript functions. Want to know how to do it?

USE THE STATUS BAR

Ever thought of that before?

There are somne security issues and it is not foolproof, but hey - what do you have to lose in these situations?

Here is an example.

Parent window (default browser window) opens up a Child window names (New_Window).

The parent window has a variable called "hello" with the string of "not_set" - The child window wants to change the string in this variable to "set".

This is the code in the child window:

----------Child Window----------
<HTML>
<HEAD>
<TITLE> </TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide me
function myfunc()
{
top.window.opener.status = "action change var hello value set";
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<button onClick="myfunc()">Click me!</button>
</BODY>
</HTML>
------------------------------
Now you might be saying "What was the good in that?", this is why.

Consider this code in the parent window:
----------Default Window----------
<HTML>
<HEAD>
<TITLE>My Page</TITLE>
</HEAD>
<BODY>
<A HREF="javascript:void(1)" onClick="window.open('secondpage.htm','new_window','resizab le')">Open second window</a>


<!-- Here is the part you want to pay attention to: -->
<SCRIPT LANGUAGE="JavaScript">
<!-- hide me
var timeout_1;
var hello;
hello = "not_set";

function repeating_func()
{
// You could make the next part a function if you
// wanted to..

if (top.window.status == "action change var hello value set")
{
hello = "set";
top.window.status = "Done";
}

timeout_1 = setTimeout("repeating_func()",100);
}

repeating_func();
//-->
</SCRIPT>

Now obviously it isn't the best code in the world for security and for speed, but this small start should probably get us further into finding a foolproof way to do these things...

Feel free to post your modifications of the code if you have done so.


Please register or log-in into NamePros to hide ads
__________________
Yeah... I knew that. What?
Mp)Tarh is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Get Me Visits http://www.mobisitetrader.com/ Thousand Dollar Profits
Advertise your business at NamePros
All times are GMT -7. The time now is 02:50 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0