SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    include within javascript

    Can you do an include within javascript? Not an include of javascript, but in javascript?

    Baring that, is there any problems with making an iframe within an iframe?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  2. #2
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    With server sided javascript yes. Unfortunately I don't know of many supports for it.

    As for iframes within iframes. I think Weirdy tried doing something similar. You may want to ask him. I have never tried, in theory yes but as for practical who knows.

    Are doing this to try and do an artificial include for javascript using a hidden iframe?
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  3. #3
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why in the world would you want an iframe within an iframe? But yes, it should, theoretically work. Not that I've tried it, but there is no reason that it shouldn't.

    You could most likely get a server side include to work, inserting the code for that in a Javascript.

    For example:

    if (var1 == 5)
    {
    <!--#include ssi.txt-->
    }
    else
    {
    <!--#include ssi2.txt-->
    }

    Not sure if your web hosting supports SSI's though. You'd have to check and make sure. Oh yeah, and name your HTML file with a .shtml extension (incase you did not know that).

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you should be able to do this, and this is how (untested code, in a hurry, off the top of my head):


    function JSInclude(IncludeURL)
    {
    document.write("<SCR" + "IPT LANGUAGE='JavaScript' SRC='" + IncludeURL + "'></SCR" + "IPT>");
    }

    (note that the opening and closing SCRIPT tags are broken into parts so that buggy browsers don't get confused)


    M@rco

    EDIT: missed closing bracket off.... told you I was in a hurry!

  5. #5
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did that work?


    M@rco

  6. #6
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by M@rco
    Did that work?


    M@rco
    I think he was talking about trying to do an include. Like with PHP. Not simply getting an external javascript file. ...

    But looking at your code it looks like it would work
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  7. #7
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had assumed from his comments about IFRAMEs that he was talking about client-side code, not server-side...n'est pas?


    M@rco

  8. #8
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by M@rco
    I had assumed from his comments about IFRAMEs that he was talking about client-side code, not server-side...n'est pas?


    M@rco
    Yep. He wanted to include something not javascript in javascript
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  9. #9
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I get it now.... Sheesh!


    M@rco


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
  •