Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Random Iframe content script problem

  1. #1
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Iframe content script problem

    1) Script Title: Random iframe content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ndomiframe.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...

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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.
    Last edited by jscheuer1; 03-16-2007 at 02:12 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

  9. #9
    Join Date
    Mar 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    dear,
    i use this code in a iframe and then paste the javascript code in this frame, what next it please tell me..

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Whatever you like. All I set out to show is that the back button now works properly.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •