Register  |  Login




Advertisement

Start Your Own Q&A Site

Create your own Q&A site easily, allowing you to quickly grow a new community around any subject matter or generate new organic traffic for your existing website.

Question

Status: Closed Points: 100 Time: 07:15 - Dec 29, 2006  

mary2

Is there a way to have includes for html prototypes in Javascript or something else?

I am creating protoypes in HTML and CSS and I wanted to see if there was an easier way to have the same thing show up over and over again. Is there any way to have include files in JavaScript that would contain HTML tables, cells, CSS, etc?

Answer Discussion
Tutorials

 

xarcus

Date:: Dec 29, 2006

Time:: 11:10

If you are speaking of HTML includes
there is the old "Server side includes" directive <!--#include file="header.html" -->
that works with Apache as well as MS IIS.

For Apache servers you should use the .shtml extension

Apache SSI: http://httpd.apache.org/docs/1.3/howto/s...
MS IIS SSI: http://www.microsoft.com/WINDOWS2000/en/...


mary2

Date:: Dec 29, 2006

Time:: 11:36

Is there anything that will just work on my PC on the client side?

xarcus

Date:: Dec 29, 2006

Time:: 17:23

For client side:
--start of script.js--
  function gen_table_at_id( my_id) {
   var mydiv = document.getElementById( my_id) ;
   mydiv.innerHTML = "<table><tbody><tr>"
    +"<td>Cell1</td>"
    +"<td>Cell2</td>"
      +"</tr></tbody></table>" ;
  }
--end of script.js--

<html>
<head>
 <title>Test</title>
 <script type="text/javascript" src="script.js"></script>
</head>
<body onload="gen_table_at_id('mydiv')">
<div id="mydiv">
</div>
</body>
</html>

mary2

Date:: Jan 02, 2007

Time:: 06:22

xarcus,

not sure who you are, but you're the man. That works great and saves me a ton of time for these prototypes. One more follow up question. On the html page where it says:

<body onload="gen_table_at_id('mydiv')">

Is there any way to load multiple functions at the same time from the same script.js file? I want to put all of my includes in one file and wanted to see how I would load more than one of them in the body tag.

mary2

Date:: Jan 02, 2007

Time:: 06:33

Nevermind, I just found out what the answer is.

To load more than one function, you just need to insert a semicolon ";" between functions on the onload command

Example:

<body onload="gen_table_at_id('mydiv'); gen_secondfunction('secondfunction')">

Thanks for the help.

Question Answered

This question has been closed, and points have been rewarded to the following experts:


xarcus: 100

You're welcome however to comment or give additional information or if you wish, you have the ability to write a Tutorial in the Tutorial Area.

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

No tutorials have been submitted yet. Want to be the first?

Answer this Question

New User

Email:

Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address

Registered User

Username:

Password:

Forgot Your Password?

Ask a Question

Have a new question? Ask!

You have 100 characters to use



Top Experts

View More

Rank

Expert

Points

1.

nidhi

10354

2.

oracleofDelphi

6493

3.

rcastagna

5596

4.

LAGM

4848

5.

PeterNZ

3487

6.

gonzalo

2840

7.

Mason

2770

8.

jgivoni

2303

9.

xarcus

1820

10.

Anpanman

917

Become an Expert

Register today to share your knowledge with the community and be recognized and rewarded for your contributions.


Register Here




"Psst, Quomon is a great site. Pass it on."     Tell a Friend  |   Link To Us  |   Save to Delicious  |   Digg! Digg it



Language Options

English:

www.quomon.com

Español:

www.quomon.es