473,382 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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="'+backgr+'"
bgcolor="#000000"></body>')
</script>
</html>

May 6 '06 #1
2 1280
JRS: In article <PE47g.13815$TK1.12832@fed1read06>, 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.banner" + Math.floor(1+Math.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.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.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="'+backgr+'"
bgcolor="#000000"></body>')
onload = function() {
width (self.document)
{
open();
write('<body background="'+backgr+
'" bgcolor="#000000"><\/body>');
close();
}
};
</script>
</html>

if that doesn't work, try :

onload = function() {
document.body.style.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
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...
1
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...
1
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...
2
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...
26
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...
2
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...
3
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:...
1
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 ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.