Jump to content

Hosting HTML


Cory
 Share

Recommended Posts

Hello there, question: Is it possible to host HTML externally (as you can do with JavaScript)? I'm guessing the only way to host HTML externally is through JavaScript, like so:

document.write("<b>Hello World!</b>")

I can externally host that, however, when I insert a full HTML table between the document.write tag the HTML won't appear when I place the externally hosted JavaScript snippet in the web file. Will externally hosted scripts exempt certain HTML tags or something?

Link to comment
Share on other sites

I've tried that, though. When I host "<b>Hello World!</b>", it works. However, when I host a complete table within the document.write line, it doesn't work.Works:

document.write("<b>Hello World!</b>")

Doesn't Work:

document.write("<table border=1><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr><tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>")

Does the 2nd code work for you, when hosted?

Link to comment
Share on other sites

I am no expert, but I would have thought that with multiple lines you would need either write out 'document.write("###")' lots of times, or put some braces in somewhere ({}).

Link to comment
Share on other sites

To get your included javascript document.write to work over mulitple lines you need to "escape" the new-line characters using a backslash:Taken from my own web-site to include my navigation menu into all my pages:Saved as galnavmenu.js:

document.write('\<br />\<dl id="navmenu1">\  <dt id="NavHeader">Navigation Menu</dt>\  <dd class="navbar1" id="home1"><a href="../../index.html" title="HOME">Home</a></dd>\  <dd class="navbar1"><a href="../gal02_stuff/index.html" title="Stuff">Eclectic</a></dd>\  <dd class="navbar1"><a href="../gal03_simp/index.html"  title="Simple">Minimal</a></dd>\  <dd class="navbar1"><a href="../gal04_sun/index.html"   title="Sun">Sun</a></dd>\  <dd class="navbar1"><a href="../gal05_stone/index.html" title="Stones">Standing Stones</a></dd>\  <dd class="navbar1"><a href="../gal06_flow/index.html"  title="Flowers">Flowers</a></dd>\  <dd class="navbar1"><a href="../gal07_bw/index.html"    title="Monochrome">Black and White</a></dd>\  <dd class="navbar1"><a href="../gal08_arch/index.html"  title="Archery">Archery</a></dd>\  <dd class="navbar1"><a href="../places/index.html"      title="Places Galleries">Places</a></dd>\  <dd class="navbar1"><a href="../reflect/index.html"     title="Reflections">Reflections</a></dd>\  <dd class="navbar1"><a href="../others/index.html"      title="others">Techniques</a></dd>\  <dd class="navbar1"><a href="../new/index.html"         title="new">New</a></dd>\  <dd class="navbar1"><img src="../../copywi.png" width="102" height="27" alt="" id="copyw" title="© 2007 kevin payne" /></dd>\</dl>\<!-- </div> -->\<br />\');

Then included in each page using

<script src="../galnavbar.js" type="text/javascript"></script> <!-- include the navigation bar -->

Hope this helpsKevin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...