Results 1 to 4 of 4

Thread: How to do I Resolve Relative Server Links When my HTML Source is not on Server

  1. #1
    Join Date
    Feb 2010

    How to do I Resolve Relative Server Links When my HTML Source is not on Server

    I would like to open an html file locally (not fetch it from a server) and somehow use javascript to fetch the relative resources from the server.

    One solution would be to convert all of the relative links to absolute links. I can convert the html source file anyway I wish, but ideally I would like to modify the html source as little as possible, for example insert a function that modifies the result of the src attribute.

    How would I go about this? Is there any trick I can use to define where the relative home is? Am I going to get into any scripting security gotchas?


  2. #2
    Join Date
    Feb 2006
    You can use the html <base> element, in the head of the document, to resolve any relative links on the page.


  3. #3
    Join Date
    Jul 2008
    urbana, il
    you won't be able to fetch linked resources using ajax from a file-based html document.
    you can link to images, stylesheets, and javscripts on the remote server, but not html documents.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  4. #4
    Join Date
    Feb 2010

    base element looks like exactly what I need.

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