www.webdeveloper.com
Results 1 to 7 of 7

Thread: Possible to import a page?

  1. #1
    Join Date
    Jun 2005
    Posts
    84

    Possible to import a page?

    Is it possible to import an external webpage into an existing one using java script. I was trying
    Code:
    <script type="text/javascript">
    function setPage(page){
    document.location.href = page+"?lang=en";
    }
    </script>
    <p>some text</p>
    <p>
    <a href="#" onclick="setPage('page.html')">click me</a>
    </p>
    But that ends up being like a redirect, i'm looking for something like <c:import url="page.html"/> but I can't use jsp.

  2. #2
    Join Date
    Jun 2006
    Posts
    10
    I don't know of a way unsing JS, you might want to look at SSI if that's available.

  3. #3
    Join Date
    Dec 2004
    Posts
    8,637
    The only way JavaScript can do it is if you have an IFRAME or wish to use Ajax.

  4. #4
    Join Date
    Jun 2005
    Posts
    84
    Quote Originally Posted by phpnovice
    The only way JavaScript can do it is if you have an IFRAME or wish to use Ajax.
    like this?

    Code:
    <script type="text/javascript">
    function setPage(page){
    window.test.src = page;
    }
    </script>
    
    <a href="#" onclick="setPage('d.html')">click me</a>
    <p>some text</p>
    <iframe src="" name="test" id="test">
    </iframe>
    I tried that, get no errors, but nothing happens

  5. #5
    Join Date
    Dec 2004
    Posts
    8,637
    This:

    window.test.src = page;

    should be this:

    self.frames["test"].location.href = page;

  6. #6
    Join Date
    Jun 2005
    Posts
    84
    thanks i think i have everything working correctly now

  7. #7
    Join Date
    Dec 2004
    Posts
    8,637
    You're welcome.

    Cheers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles