473,763 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JS in frame1 <--> JS in frame2

I have a page with two frames. Frame1 contains an inline script. Frame2
contains inline and 2 loaded scripts. How may I call a function in
frame1(inline) from frame2(inline or loaded)?

Albert

Jul 20 '05 #1
17 2273
Albert Wagner <al******@tcac. net> writes:
I have a page with two frames. Frame1 contains an inline script. Frame2
contains inline and 2 loaded scripts. How may I call a function in
frame1(inline) from frame2(inline or loaded)?


You have one page, which is a frameset. It contains two other pages
in frames.

To access a global variable of frame1 from frame2, you just write (in
frame2):

parent.frames['frame1'].globalVarName

<URL:file://localhost/D:/Home/lrn/html/faq/JSwindows.html# ref_3_12>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:oe******** **@hotpop.com.. .
<snip>
<URL:file://localhost/D:/Home/lrn/html/faq/JSwindows.html# ref_3_12>


Did you mean:-

<URL: http://www.infimum.dk/HTML/JSwindows.html#ref_3_12 >

Richard.
Jul 20 '05 #3
"Richard Cornford" <ri*****@litote s.demon.co.uk> writes:
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:oe******** **@hotpop.com.. .
<URL:file://localhost/D:/Home/lrn/html/faq/JSwindows.html# ref_3_12>


Did you mean:-
<URL: http://www.infimum.dk/HTML/JSwindows.html#ref_3_12 >


DOH!
Thanks.

/L 'Must. Be. More. Careful!'
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:k7******** **@hotpop.com.. .
<snip>
Did you mean:-
<URL: http://www.infimum.dk/HTML/JSwindows.html#ref_3_12 >


DOH!
Thanks.


Incidentally, I liked the page, though you could have mentioned browsers
that lack the window.open function (PDA and embedded) in the "Problems
with opening windows" section.

Richard.
Jul 20 '05 #5
On 12 Sep 2003 00:31:25 +0200
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote:
<snip>
You have one page, which is a frameset. It contains two other pages
in frames.

To access a global variable of frame1 from frame2, you just write (in
frame2):

parent.frames['frame1'].globalVarName

<URL: file://localhost/D:/Home/lrn/html/faq/JSwindows.html# ref_3_12 >


Thank you, Lasse, for both your exellent reply and the link. I've been
saveing all the good links from this NG.
Jul 20 '05 #6
On Thu, 11 Sep 2003 23:02:51 +0000 (UTC), "Richard Cornford"
<ri*****@litote s.demon.co.uk> wrote:
Incidentally , I liked the page, though you could have mentioned browsers
that lack the window.open function (PDA and embedded) in the "Problems
with opening windows" section.


One of the interesting things in opera 6.0 on Series 60 Symbian
devices is that javascript defaults to OFF, but pop-ups default to on,
which seems kind of odd.

(I hope to be looking further into Opera/Netfront and others on Series
60 phones so, both claim DOM/DHTML)

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7
"Richard Cornford" <ri*****@litote s.demon.co.uk> writes:
Incidentally, I liked the page,
Thanks!
though you could have mentioned browsers
that lack the window.open function (PDA and embedded) in the "Problems
with opening windows" section.


Consider it done and uploaded.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #8
On 12 Sep 2003 00:31:25 +0200
Lasse Reichstein Nielsen <lr*@hotpop.com > wrote:
<snip>

I tried your suggestion and the link, but no joy. I have included the
code and the error. Any criticisms or advice are welcome. Thanks
ahead.

Albert

========== test.html =============== =============== ===========
<HTML>
<HEAD>
<TITLE>Test and Debug</TITLE>
</HEAD>
<FRAMESET ROWS="30%,70%" COLS="30%,70%">

<FRAME SRC="debugger.h tml" NAME="debugFram e" ID="debugFrame" >
<FRAME SRC="program.ht ml" NAME="programFr ame" ID="programFram e">

</FRAMESET>
</HTML>

=========== debugger.html =============== =============== ======
<HTML>
<HEAD>
<TITLE>Debugger </TITLE>
<SCRIPT type="text/JavaScript">

var DebugPrint = function(_line) {
debugFrame.docu ment.writeln("< p>"+_line+"</p>");
}

function Initialize() {
debugFrame = window.parent.f rames.debugFram e;
DebugPrint("Deb ugger started.");
}

</SCRIPT>
</HEAD>
<BODY onLoad="Initial ize()">
</BODY>
</HTML>

=========== program.html =============== =============== ==========
<html>
<head>
<title>JavaScri pt-Test</title>
<script type="text/javascript">
var Print = function(_line) {
programFrame.do cument.writeln( '<br>'+_line+' </br>');
}

function Initialize() {
programFrame = window.parent.f rames.programFr ame;
Print("Program started.");
window.parent.f rames.debugFram e.DebugPrint("F rom Program"); // error
this line
}
</script>
</head>
<body onLoad="Initial ize()">
</body>
</html>

============ JavaScript Console / Opera 7.11 =============== ========

Event thread: onload
Error:
name: TypeError
message: Statement on line 9: Expression did not evaluate to a function
object: window.parent.f rames.debugFram e.DebugPrint
Backtrace:
Line 9 of inline#1 script in
file://localhost/usr/js/work/mover/program.html
window.parent.f rames.debugFram e.DebugPrint("F rom Program");
In unknown script
Initialize();
At unknown location
{event handler trampoline}
Jul 20 '05 #9
Albert Wagner <al******@tcac. net> writes:
<FRAME SRC="debugger.h tml" NAME="debugFram e" ID="debugFrame" >
<FRAME SRC="program.ht ml" NAME="programFr ame" ID="programFram e">
I recommend against having the same "name" and "id" attribute values.

In both HTML and XHTML, "name" is a valid attribute name for frames.
If you need the "id" attribute, add "Id" to the end of it, or something
similar.

=========== debugger.html =============== =============== ====== var DebugPrint = function(_line) {
debugFrame.docu ment.writeln("< p>"+_line+"</p>");
If we are in the debugFrame, then it suffices to write
document.writel n(...);
The scope rules will garantee that we always refer to the current
frame's document object

You should escape the "</" token. The recommended way is "<\/".

I.e.:
document.writel n("<p>"+_line+" <\/p>");
}

function Initialize() {
debugFrame = window.parent.f rames.debugFram e;
This is in the debugFrame, so "debugFrame = window" should be
equivalent.
DebugPrint("Deb ugger started.");
Here you make a document.write to the current document. That completely
erases the current document and starts writing a new one. Erasing the
current document also loses the debugFrame function. So, if this page
loads faster than the program page, then it erases the function before
it can be called.
=========== program.html =============== =============== ========== var Print = function(_line) {
programFrame.do cument.writeln( '<br>'+_line+' </br>');
As above. Change "</br>" to "<\/br>". The "programFra me." isn't
necessary ...
}

function Initialize() {
programFrame = window.parent.f rames.programFr ame;
.... and this can be shorter (or omitted)
Print("Program started.");
Here you erase the current page. The running function isn't lost before
it finishes, so the next line is executed.
window.parent.f rames.debugFram e.DebugPrint("F rom Program"); // error
this line
If this frame loads faster than the debug frame, then the function
isn't available yet. If it is slower, the debug frame erases it again.

There is a very narrow margin where this could possibly work.
message: Statement on line 9: Expression did not evaluate to a function
object: window.parent.f rames.debugFram e.DebugPrint


.... and therefore it most likely fails every time.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1335
by: sravi | last post by:
I have a webpage which contains two frames, let us call this as main page and the frames as frame1 and frame2. Now if i click any link in frame1 or frame2 a script in main page should be invoked. Assume im not able to change the source code of frame1 and frame2. I can only change the source code of main page. Is there any way. Also the links may point anywhere, not necessarily "javascript:fn()". i.e., can i control the links in...
3
1748
by: Robin | last post by:
Hi, I have a question: If I have a frameset, frame1 and frame2. On frame2 I have a datagrid, on which I can add/update/delete rows. If I submit that page, I catch these changes in events and update my objects with it. Now do I want a button in frame1, which does save. The problem is that I first want to submit the page in frame2 to update my objects, before
2
1636
by: dr_tella_nu | last post by:
Hello World, the following code throws this error: error c2039: 'z' : is not a member of 'a' #include <iostream> using namespace std;
3
1408
by: misra.manisha | last post by:
Hi, I am using frames (I know that its not a good practice, but I have to). Each of these frames have separate form variables, all of which are needed in the parent frame. Now, the problem is that only one frame in the parent frame has a submit button. Is there any way in which I can submit the forms of other frames on click of the submit of this particular frame? I mean, is there any way in which I can access the forms in JSPs of...
0
1367
by: PointyPointy | last post by:
Hey, I'm hoping some can help me out with a small problem I'm having. I've got two frames - Frame1 and Frame2. Both have aspx pages (Primarily VB) loaded in them but to keep this explination simple, I'll refer to them by their frame names. Frame1 has some text boxes. The user enters some values and clicks an asp button which then loads those values in session variables (Yea I know - bad me for using session variables). All that...
3
6217
by: ApoorvaDesai | last post by:
I have 2 frames and on a button click event on frame 1 I want to hide frame 1 and show frame 2 I can hide frame 1 but frame 2 does not appear. I would really appreciate all the help. I am learning progamming so please go easy on the terminologies Heres the code ***********app1.py*******autogenerated code import wx
4
1459
by: vmars956 | last post by:
Greetings; 11/01/2008 I am stepping thru: "Getting Started Guide for Boa Constructor Kevin Gill November 1, 2000 March 2005 updated for Boa 0.4.0 July 2007 updated for Boa 0.6.0 by Werner F. Bruhin " And everything works great, until I select the AboutMenu item. It does absolutely nothing, as far as Dialog2 is concerned. If I put some other code in 'AboutMenu' , instead of Dialog2 stuff, 'AboutMenu' works fine. So I know that...
0
1520
by: cindrie | last post by:
please correct my code using boa constructor ------------frame1--------------- #Boa:Frame:Frame1 import wx import Frame2 import Frame3
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10145
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9998
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.