473,776 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Script in iframe unintentionally halting script in parent

I have a script that writes the body tag and adds a background
image to its containing page. This page is displayed in an
iframe inside a td tag of a table constructed with javascript.

The table row it appears in is mid-way down the table. When the
script executes in the iframe it halts the parent window's
script, casusing the table to stop rendering after the row
containing the iframe.

I have no control over the code of the parent window.

Is this behavior normal for javascript? Is there anything I can
do with my code to compensate for the behavior of code in the
parent window?

My code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
</head>
<script>
var backgr2="images/banner2.gif"
var backgr3="images/banner3.gif"
var backgr4="images/banner4.gif"
var backgr5="images/banner5.gif"
var backgr6="images/banner6.gif"
var backgr7="images/banner7.gif"
var cur=Math.round( 7*Math.random() )

if (cur<=2)
backgr=backgr2
else if (cur<=3)
backgr=backgr3
else if (cur<=4)
backgr=backgr4
else if (cur<=5)
backgr=backgr5
else if (cur<=6)
backgr=backgr6
else
backgr=backgr7
document.write( '<body background="'+b ackgr+'"
bgcolor="#00000 0"></body>')
</script>
</html>

May 6 '06 #1
2 1300
JRS: In article <PE47g.13815$TK 1.12832@fed1rea d06>, dated Sat, 6 May
2006 10:02:39 remote, seen in news:comp.lang. javascript, Penguiniator
<no*****@spamme .com> posted :
var backgr2="images/banner2.gif"
var backgr3="images/banner3.gif"
var backgr4="images/banner4.gif"
var backgr5="images/banner5.gif"
var backgr6="images/banner6.gif"
var backgr7="images/banner7.gif"
var cur=Math.round( 7*Math.random() )

if (cur<=2)
backgr=backgr2
else if (cur<=3)
backgr=backgr3
else if (cur<=4)
backgr=backgr4
else if (cur<=5)
backgr=backgr5
else if (cur<=6)
backgr=backgr6
else
backgr=backgr7

backgr = "images.ban ner" + Math.floor(1+Ma th.random()*6) + ".gif"

will do what I suppose you intended there.

Read the newsgroup FAQ, via sig line 2, particularly S 2.3 & S 4.22.

Don't let your posting agent line-wrap your code.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
May 6 '06 #2
ASM
Penguiniator a écrit :
I have a script that writes the body tag and adds a background
image to its containing page. This page is displayed in an
iframe inside a td tag of a table constructed with javascript.
Why not to do more complicated ?
Is it an exercise ?
or do you like too much to slide on your iceberg ?

My code:
is it the code of file in your iframe ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Why xmlns ?
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
</head>
<script>
<script type="text/javascript">
var backgr2="images/banner2.gif"
var backgr2="images/banner2.gif";
var backgr3="images/banner3.gif"
var backgr4="images/banner4.gif"
var backgr5="images/banner5.gif"
var backgr6="images/banner6.gif"
var backgr7="images/banner7.gif"
var cur=Math.round( 7*Math.random() )

if (cur<=2)
backgr=backgr2
else if (cur<=3)
backgr=backgr3
else if (cur<=4)
backgr=backgr4
else if (cur<=5)
backgr=backgr5
else if (cur<=6)
backgr=backgr6
else
backgr=backgr7
document.write( '<body background="'+b ackgr+'"
bgcolor="#00000 0"></body>')
onload = function() {
width (self.document)
{
open();
write('<body background="'+b ackgr+
'" bgcolor="#00000 0"><\/body>');
close();
}
};
</script>
</html>

if that doesn't work, try :

onload = function() {
document.body.s tyle.background = "url('+ backgr +
') repeat top left #000000";';
};

--
Stephane Moriaux et son [moins] vieux Mac
May 7 '06 #3

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

Similar topics

3
9306
by: Catherine Lynn Smith | last post by:
I want to know the recommended way to handle scripting of/with containers such as an iframe. I have a page with border-navigation bars on the top/bottom/left/right and I want to use an iframe to load content in the middle. I would like, if possible, to have the parent window resize itself to suit whatever is loaded into the iframe container, deriving the size needed from calculated values. Thus the calculation would have to over-ride...
1
1757
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is true it will run a java script dynamically to update the parent page CustomerSlides.aspx.cs. The value in the Database is changed from another aspx page så all the changes made in this page will be updated in CustomerSlides.aspx. I used the code...
1
1806
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is true it will run a java script dynamically to update the parent page CustomerSlides.aspx.cs. The value in the Database is changed from another aspx page så all the changes made in this page will be updated in CustomerSlides.aspx. I used the code...
2
4557
by: Randell D. | last post by:
Folks, I have got this working before, in part with some help from this ng but I never really understood how I got it working... and last time, I was using it via a popup window as opposed to an IFRAME. I've got several months of javascript under my belt and can resolve most things without errors in my Mozilla Javascript Console, but this one just does not do it for me. This is the picture:
26
45524
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
2
2976
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a url page
3
3337
by: Jeremy | last post by:
If we have an iframe loaded from the same domain as the parent document, how can we (is it possible) to execute a function on the parent document's page? e.g. 1) On parent page: ------------------ <script type="text/javascript">
1
3953
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need my objective is this that when i uplod a file it should be desply on same page with ajax uplod after when i refresh page this should be not remains longer and on clicking other image its replase previous image plz help how i can do this the...
0
10289
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
10120
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
8952
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7471
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6722
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
5367
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...
0
5493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.