Results 1 to 7 of 7

Thread: It is possible to add 2 random iframe in one single page?

  1. #1
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default It is possible to add 2 random iframe in one single page?

    Hi,

    Is there any professional about javascript here? I would like to know if it's possible to load two random iframe in one single page.

    I'm using this as the random iframe:
    <script language="JavaScript1.2">

    //Random iframe content- © Dynamic Drive (www.dynamicdrive.com)
    //For full source code, and Terms Of use, visit http://dynamicdrive.com
    //This credit MUST stay intact for use

    var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1

    //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 (ie||dom)
    document.write('<iframe id="dynstuff" src="" '+iframeprops+'></iframe>')

    function random_iframe(){
    if (ie||dom){
    var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff
    iframeobj.src=randomcontent[Math.floor(Math.random()*randomcontent.length)]
    }
    }

    window.onload=random_iframe

    </script>
    It is possible to add 2 random script in one single page?

    Thanks.

  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 2 random iframes

    You should check out this thread, the modifications and subsequent positioning issues that may arise are almost identical:

    Need help configuring 3 DD scripts on same page - Daily IFrame Content

    Once you go through that material, if you still have questions, let me know.

  3. #3
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the reply.

    I tried the whole thing in the page you shown me and it's still not work...

    I want to put 2 RANDOM IFRAME at a single page. Following the step shown by jscheuer1, it still doesn't work I don't know why... It only shows 1 random iframe of 2. I want 2 random iframe that show at the same time.

    Could you check this for me please?

    Please click on the link below and tell what is missing...
    http://www.adpaid.info/member/jamewoong

    Thanks.

    Note:
    The content "page to page6" isn't created yet. Just check for me if the script is correct or not.

  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

    That was a mess. Oh well, that's what I get for not giving better instructions. Here is a modified script that should work, and BTW, please leave the credit intact this time:

    Code:
    <script type="text/javascript">
    
    //Random iframe content- © Dynamic Drive (www.dynamicdrive.com)
    //Modified to produce 2 Random iframes
    //For full source code, and Terms Of use, visit http://dynamicdrive.com
    //This credit MUST stay intact for use
    
    var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1
    var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1
    
    //Specify IFRAMEs display attributes
    var iframeprops1='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'
    var iframeprops2='width=130 height=130 marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="1" scrolling="no"'
    
    //Specify random URLs to display inside 1st iframe
    var randomcontent1=new Array()
    randomcontent1[0]="random1_1.htm"
    randomcontent1[1]="random1_2.htm"
    randomcontent1[2]="random1_3.htm"
    randomcontent1[3]="random1_4.htm"
    
    //Specify random URLs to display inside 2nd iframe
    var randomcontent2=new Array()
    randomcontent2[0]="random2_1.htm"
    randomcontent2[1]="random2_2.htm"
    randomcontent2[2]="random2_3.htm"
    randomcontent2[3]="random2_4.htm"
    
    //No need to edit after here
    if (ie||dom)
    document.write('<iframe id="dynstuff1" src="" '+iframeprops1+'></iframe><br>')
    document.write('<iframe id="dynstuff2" src="" '+iframeprops2+'></iframe>')
    
    function random_iframe(){
    if (ie||dom){
    var iframeobj1=document.getElementById? document.getElementById("dynstuff1") : document.all.dynstuff
    iframeobj1.src=randomcontent1[Math.floor(Math.random()*randomcontent1.length)]
    var iframeobj2=document.getElementById? document.getElementById("dynstuff2") : document.all.dynstuff
    iframeobj2.src=randomcontent2[Math.floor(Math.random()*randomcontent2.length)]
    }
    }
    
    window.onload=random_iframe
    
    </script>
    This will produce two random iframes, one after the other vertically. If you need different positioning, let me know.

  5. #5
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much!!! How come I didn't find the error?

    About the credit, I apologize for that. My page was ENCRYPTED, it is why I removed the credit, because it will take space. Also, it's impossible for some to see it.

    If you really want me to let the credit intact when the page will be encrypted, so I'll have no choice to respect you and let the credit there...\

    Sorry again...

  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

    Glad I could help.

    About the credit, I'm not affiliated with DD, I just think it is good ethics to include a credit for work freely offered when it is requested. So much so, that I would at least make the effort to include it, not encrypted, in such a case like this. You could easily, after encrypting the page, put this at the very top (right after the !DOCTYPE, if used), before anything else or at the bottom after everything else:

    HTML Code:
    <!-- This page includes:Random iframe content- © Dynamic Drive (www.dynamicdrive.com).  Modified to produce 2 Random iframes.  For full source code, and Terms Of use, visit http://dynamicdrive.com.  This credit MUST stay intact for use. -->
    That should not mess anything up and be there for the snoopers to see. BTW, if you do use a !DOCTYPE declaration, there is no need to encrypt it.

  7. #7
    Join Date
    Mar 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    Thanks to comment. I'll add it.

    By the way, everyone knows that DynamicDrive.com is the only place to get the BEST javascript...

    My first time to get javascript is from here

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
  •