PDA

View Full Version : Random Iframe content script problem



shahjee99
03-16-2007, 12:32 PM
1) Script Title: Random iframe content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/randomiframe.htm

3) Describe problem: I use this on my page in a iframe the problem is that when i going forward on any page and then going back to click browser back button, the content in the ifame only change whole page doesn't go back please help me soon i am very very thankful to you alls
Thanx in advance...

jscheuer1
03-16-2007, 02:05 PM
That is bound to happen due to the fact that the script adds its content as a source change, adding to the history stack. This version will not do that:


<script type="text/javascript">

//Random iframe content- &#169; Dynamic Drive (www.dynamicdrive.com)
//For TOS source code, and Terms Of use, visit http://dynamicdrive.com
//This credit MUST stay intact for use
//Modified here to not add to the history stack
//by jscheuer1 in http://www.dynamicdrive.com/forums

//Specify IFRAME display attributes
var iframeprops='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'

//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="random1.htm"
randomcontent[1]="random2.htm"
randomcontent[2]="random3.htm"
randomcontent[3]="random4.htm"

//No need to edit after here
if (document.getElementById||document.all)
document.write('<iframe id="dynstuff" src="'+randomcontent[Math.floor(Math.random()*randomcontent.length)]+'" '+iframeprops+'></iframe>')

</script>


Note: This will make the iframe retain its content until the page is navigated to afresh (using the back and forward buttons or refresh will generally not get you new content). You will need to click on a link to it or paste its address into the address bar and hit enter to get a change.

shahjee99
03-16-2007, 02:19 PM
Dear,
This script also do the same as previous, i check it but it also not go back properly please help me or tell me any other way to show random html contents in a iframe and also go back properly thanx in advance

jscheuer1
03-16-2007, 02:24 PM
I think you may have the old version in your browser's cache or may have made some error or there is something else causing the problem. Please supply a link to your problem page.

shahjee99
03-16-2007, 02:36 PM
dear
i am not uploaded the page yet, i create on my computer when i made it then i upload files so how can i show you the link please please please help me i am tired to correct this problem, i am working on my site from morning to till now but i don't understand where is problem, no error shown nothing happend everything ok content shown only this back page problem does't solve by me, i use iframe and the use .js all thing is okie please tell me soon i am waiting for your reply thanx in advance

jscheuer1
03-16-2007, 02:48 PM
It is possible I overlooked something, but not too likely. I did test this out in several browsers here locally.

Without seeing the pages, I can only guess that you need to clear your browser's cache. Make sure you are viewing the new page by using your browser's 'view source' to confirm that that the loaded page uses the updated script. As this is a complex situation, involving several pages, if you need more help, I would need to see a live demo of the problem. Include with your link exact instructions as to how to duplicate the problem.

shahjee99
03-16-2007, 02:51 PM
dear,
if u have any online demo with this code please give me the link i will see it and then post you the result what happened with me thanx in advance

jscheuer1
03-16-2007, 03:00 PM
http://home.comcast.net/~jscheuer1/side/random_help/

shahjee99
03-16-2007, 05:01 PM
dear,
i use this code in a iframe and then paste the javascript code in this frame, what next it please tell me..

jscheuer1
03-16-2007, 05:03 PM
Whatever you like. All I set out to show is that the back button now works properly.

shahjee99
03-16-2007, 05:15 PM
I want only know one more thing that which url you send to me i check it, it works okie but one thing you refresh the page many time you show only one page means contents not change randomly so smoothly please its last question to you i am very very thankful to you.. i check it again and again but i can't solve the problem. thanx in advance

jscheuer1
03-16-2007, 05:22 PM
I already mentioned that, sometimes you have to give up one thing to get another. In Opera it does change with refresh, not so in IE and FF. However, repeated refreshing is not the usual way people will navigate to it. They usually will come via link. When they do that, the content will be random.

shahjee99
03-16-2007, 05:28 PM
Dear,
I am so much in trouble, i want that every refresh the page these contents should be change, but you said it is not possible i am very very tired for one script, please please please u r so genius please give me any script that give me random contents with refresh and also back page going well please, i always remember you please, the random iframe content script is going well, it change randomly contents but the back button problem in it, and which u give me url is back button okie but not randomly change, is there any possibiliy to combine both code and make my code please

jscheuer1
03-16-2007, 08:32 PM
Ah, I found a way. I've updated the demo:

http://home.comcast.net/~jscheuer1/side/random_help/

Here's the new code:


<script type="text/javascript">

//Random iframe content- Dynamic Drive (www.dynamicdrive.com)
//For TOS source code, and Terms Of use, visit http://dynamicdrive.com
//This credit MUST stay intact for use
//Modified here to not add to the history stack
//by jscheuer1 in http://www.dynamicdrive.com/forums

//Specify IFRAME display attributes
var iframeprops='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'

//Specify random URLs to display inside iframe
var randomcontent=new Array()
randomcontent[0]="random1.htm"
randomcontent[1]="random2.htm"
randomcontent[2]="random3.htm"
randomcontent[3]="random4.htm"

//No need to edit after here
if (window.frames&&window.location.replace)
document.write('<iframe name="dynstuff" src="" '+iframeprops+'></iframe>')

function random_iframe(){
if (window.frames&&window.frames['dynstuff']&&window.frames['dynstuff'].location.replace)
window.frames['dynstuff'].location.replace(randomcontent[Math.floor(Math.random()*randomcontent.length)]);
}

window.onload=random_iframe

</script>

shahjee99
03-17-2007, 04:24 AM
Dear,
You did it very nice, wow so much genius person you are amazing, i am really really happy from you, thanks thanks thanks thanks thanks thanks, please give your brain so can i invent new things, nice i really really want this script, and you know many user in this forum want this kind of script, salute to you, thanks again