/    Sign up×
Community /Pin to ProfileBookmark

change iframe src on page reload

How can I change iframe source every time when page is reloaded??

to post a comment
HTML

10 Comments(s)

Copy linkTweet thisAlerts:
@HoxieJun 03.2008 — How can I change iframe source every time when page is reloaded??[/QUOTE]

You can run a php script in the page being pulled by the iframe. Im sure you can do a quick google search for something that would work.
Copy linkTweet thisAlerts:
@TheBearMayJun 03.2008 — [code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var srcArr = new Array();
srcArr[0]="pg1.htm";
srcArr[1]="pg2.htm";
srcArr[2]="pg3.htm";

window.onload = function (){
var ranNum=Math.floor(Math.random()*(srcArr.length));
document.getElementById("randomFrme").src=srcArr[ranNum];
}
</script>
</head>

<body>
<iframe id="randomFrme"></iframe>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@mukkiiauthorJun 03.2008 — thanks, but it's not working. ?
Copy linkTweet thisAlerts:
@TheBearMayJun 03.2008 — thanks, but it's not working. ?[/QUOTE]What error are you getting?
Copy linkTweet thisAlerts:
@mukkiiauthorJun 04.2008 — What error are you getting?[/QUOTE]

the content of iframe (pages) won't show up.
Copy linkTweet thisAlerts:
@KorJun 04.2008 — Show us the code or a link to a test page
Copy linkTweet thisAlerts:
@mukkiiauthorJun 04.2008 — Show us the code or a link to a test page[/QUOTE]

[url]http://www.sigurantip.com/euro/index.php[/URL]

The iframe should appear on right end.
Copy linkTweet thisAlerts:
@KorJun 04.2008 — Yea, I could have bet from the beginning that you have more than a single [B]window.onload[/B].

There are several solutions. One of them: Remove the red from
<i>
</i>&lt;body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" [COLOR="Red"]onLoad="preloadImages('images/buttons/naslovna-over.gif','images/buttons/vodic-over.gif','images/buttons/rep-over.gif','images/buttons/grupe-over.gif','images/buttons/ras-over.gif','images/buttons/stat-over.gif','images/buttons/his-over.gif','images/buttons/slike-over.gif','')"[/COLOR]&gt;

and call that function along with the others stetemnts, in a single window.onload handler (add the blue):
<i>
</i>window.onload = function (){
var ranNum=Math.floor(Math.random()*(srcArr.length));
document.getElementById("randomFrme").src=srcArr[ranNum];
[COLOR="Blue"]preloadImages('images/buttons/naslovna-over.gif','images/buttons/vodic-over.gif','images/buttons/rep-over.gif','images/buttons/grupe-over.gif','images/buttons/ras-over.gif','images/buttons/stat-over.gif','images/buttons/his-over.gif','images/buttons/slike-over.gif','');[/COLOR]
}
Copy linkTweet thisAlerts:
@mukkiiauthorJun 04.2008 — ? aaa, great, thanks! So in the whole code there can be only one window.onload. call. Thanks for that too. ?
Copy linkTweet thisAlerts:
@KorJun 04.2008 — It is a general rule, not only for [B]window.onload[/B]. In the whole code should be only a single event of the same type applied upon the same element. There are javascript methods to [I]add[/I] new functions to be called within a pre-existent event, but this is another topic.
×

Success!

Help @mukkii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...