Results 1 to 16 of 16
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    Hi all,

    Is there a way to use JavaScript to allow a web page to call some HTML code from another web site?

    With Server Side Includes you can do this for HTML on the same site, like the HTML for a navigation bar.

    What I'm wondering is if there's a way to call up a snippet of code from another domain? And if so how would one do so?

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  2. #2
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    1,658
    Well, assuming that it's OK for you to use the "other site's" code. Why not just cut & paste?

    CJ Rocks! CJ Rocks! CJ Rocks! CJ Rocks!

  3. #3
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    LOL, nothing sketchy going on.... I own all the sites.

    I want to do that so I can have certain code in one place but shown on several sites. That way if I make a change I only have to do it once. A lot less likely to make a mistake that way.

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  4. #4
    Member
    Join Date
    January 18th, 2005
    Posts
    84
    You can do something like this:

    <script src="http://www.someplace.com/placeofcode">
    </script>

    The issue is that where it pulls has to be valid javascript code, so if it's html code, you'll have to write it all in something like:

    document.write('<html><head>...');

    And escape all your single, double quotes and slashes.

    Mark Wolinski
    GigaGolf, Inc

  5. #5
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    lagged comment & reposted.

  6. #6
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    Mark W is right on the money with his suggestion.

    DesignerWiz.com CEO
    Development Resource & Javascript Public Archive Center
    http://DesignerWiz.com

  7. #7
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    Hello Nexus,

    We just had time to visit your service and was curious about the nautical ships and reseller opportunity.

    We tracked your payment center LinkPointCart and noted it does not offer tracking affiliates. Just how are you tracking your affiliate tier anyway?

    DesignerWiz.com CEO
    Development Resource & Javascript Public Archive Center
    http://DesignerWiz.com

  8. #8
    Full Member
    Join Date
    January 18th, 2005
    Posts
    322
    I just visited the site too. I might have to join the affiliate program so I can earn the money for that USS Constitution model. So lets see, I would have to sell how many ships….

    Jason
    “That’s the song I’ve been sangin for years, that’s the way the wild wind blows” – Robert Earl Keen

  9. #9
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    Hi all,

    Our shopping cart is LinkPointCart. We use My Affiliate Program to track affiliate commissions from the cart.

    I'm looking at the Javascript now and trying some stuff out (thanks Mark W!) and will report back on my results soon.

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  10. #10
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    Mark,

    I am a little confused about how to implement the JS. I understand the escape characters. What I'm trying to figure out is where to place the <script src="http://......"></script> and the document.write('<head>....'); commands.

    I tried it with the <script> tags in the head of the page where I want to call the html, and I also tried it with that in the body instead.

    E.G. I had this in the page at www.domain2.com where I wanted to display the HTML:

    <script src="http://www.domain1.com/test.html">
    </script>

    Then I saved this as test.html and put it at www.domain1.com:

    document.write('[escaped html here]');

    When I loaded the page it loaded just like a regular page without the JS. I was thinking of using it with an onLoad command but I'm not sure if that's what's needed.

    I'm not calling the script am I? Thanks for all your help.

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  11. #11
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    Oh, I meant "When I loaded the page it loaded just like a regular page..." that I was loading the page at domain2.com that had the <script> tags.

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  12. #12
    ABW Ambassador DesignerWiz's Avatar
    Join Date
    January 18th, 2005
    Location
    U.S.A
    Posts
    2,777
    Hello David,

    Ohhhh ... I think I see what you are saying now. I believe what you are referring to is a document in document scriptlet. Only bad thing is, only IE users support such features and NS viewers will see absolutely nothing.

    Ray Thomas
    DesignerWiz.com CEO
    Development Resource & Javascript Public Archive Center
    http://DesignerWiz.com

  13. #13
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    Umm - a note here - do all you can on the server side - a great number of people turn off, or don't have browsers that'll run Javascript. If you are going to include a chunk from another site, do it at the server level if at all possible.

    Ford Fox-body Owners Club
    http://www.ford-fox.org

  14. #14
    Member
    Join Date
    January 18th, 2005
    Location
    Cape Cod, MA
    Posts
    57
    This may be of some help:

    Same server?
    http://www.smarterscripts.com/includer/

    Different servers?
    http://www.smarterscripts.com/executer/

  15. #15
    Newbie
    Join Date
    January 18th, 2005
    Posts
    39
    Thanks for all the help everyone. I've been looking at the suggestions and haven't quite found a solution yet. I'm going to let it gestate for a while and see if my subconsciousness will have a eureka moment.

    David Nguyen
    Nexus Imports, LLC
    http://www.nexusimports.com/affiliates/index.shtml

  16. #16
    ABW Ambassador Joey's Avatar
    Join Date
    January 18th, 2005
    Posts
    549
    Another alternative is to use an iframe. Iframes won't integrate into your site as nicely as javascript can, but will save you the trouble of having to escape HTML characters inside your javascript.

    Of course you may also want to keep in mind that a search engine will read SSI as part of the page, but will ignore javascript and iframes.

  17. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Replies: 23
    Last Post: December 31st, 2006, 03:33 PM
  2. Server Side Includes
    By Roland in forum Midnight Cafe'
    Replies: 5
    Last Post: April 25th, 2005, 11:55 AM
  3. If you use Front Page and don't understand Server Side Includes
    By SSanf in forum Programming / Datafeeds / Tools
    Replies: 21
    Last Post: December 6th, 2004, 10:46 AM
  4. Server Side Include Files
    By frankodelic in forum Search Engine Optimization
    Replies: 6
    Last Post: February 14th, 2003, 12:49 AM
  5. Server side tracking solutions?
    By madmanbc in forum Search Engine Optimization
    Replies: 1
    Last Post: February 9th, 2002, 08:37 PM

Posting Permissions

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