dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: html into js var

  1. #1
    Join Date
    Aug 2003
    Posts
    30

    html into js var

    is there a way to extract the html source from a given url? I need to put this into a js vert scroller and can't seem to find any other way to do embed the data.

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Javascript only has access to the content of the current web page. It can't read anything from a different page.

  3. #3
    Join Date
    Aug 2003
    Posts
    30
    Thanks Felgall... Do I have any options? How can I embed html from a given URL into a js var?

    Best,
    Craig

  4. #4
    Join Date
    Jan 2005
    Location
    Los Angeles, CA
    Posts
    4,887
    There are in fact a couple of methods to avoid the cross-server security issue.
    1. Change your HTM or HTML extension to HTA
    2. load the hyperlink into an image and get the content from the error details
    3. load the hyperlink into a SCRIPT tag and get the content
    4. the most practical choice would be to go server-side
      you would have a PHP program e.g. that will accept a parameter for the hyperlink and the PHP file will return the source of the website but with quotes around it preceeded by daSource= so you can just load it as an external JavaScript file so JavaScript only needs to access the variable daSource
    Last edited by Ultimater; 09-12-2005 at 07:41 PM.

  5. #5
    Join Date
    Aug 2003
    Posts
    30
    Thanks Ultimater,

    You have given me some hope here. I haven't done any of my server side stuff yet. I need to do hit counters and form to mail CGI's, I'm not sure I have access to PHP and to be honest I've never done any PHP scripting. Can you tell me more about your #3 load the hyperlink into a SCRIPT tag and get the content, option you gave. This might be my simplest solution right now but I'd be open to anything that works right now.

    Best,
    Craig

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