dcsimg
www.webdeveloper.com
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
    Posts
    2

    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?

    Thanks

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



    http://w3schools.com/tags/tag_base.asp

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    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.

  4. #4
    Join Date
    Feb 2010
    Posts
    2
    thanks.

    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