Click to See Complete Forum and Search --> : pass text to a div?


LAwebTek
02-11-2003, 11:36 PM
Is it possible to pass html and text to a span or a div or something? I don't want to use an iframe or any frames if I don't have to.

pyro
02-11-2003, 11:49 PM
Is this what you are looking for?

<script language="javascript" type="text/javascript">
document.getElementById("text").innerHTML = 'This is where your text goes';
</script>

<div id="text"></div>

LAwebTek
02-12-2003, 07:52 AM
Thank you, that was exactly what I was looking for!

pyro
02-12-2003, 08:01 AM
One other thing...Sind it is using innerHTML, you could pass this if you wanted to...

document.getElementById("text").innerHTML = '<b>Hello World</b>';

and it would print this to your div

Hello World

khaki
02-12-2003, 10:31 AM
I tried putting the script into a seperate JS file and the <div> into a HTML file (and referenced the JS file as a source).

Didn't work (for me).

Can it be done that way?
Thinking of possibilities...
k

LAwebTek
02-12-2003, 10:39 AM
Here's what I ended up doing. DefC() is the default page content and getC() is called by the page navigation for "Standard Services". getC2() will be "Advanced Services", etc...

function defC() {
document.getElementById('content').innerHTML='<br><p align="center">'
+ '<font face="Verdana, Arial, Helvetica, sans-serif" size="4">Reliable '
+ 'Application Development</font></p><br><p><font face="Arial" size="2">'
+ '<a href="about.html">L-A WebTek</a> develops high quality web sites, applications, '
+ 'and marketing creatives. Take a look at our <a href="standard.html">Standard</a> '
+ 'and <a href="advanced.html">Advanced</a> Services '
+ 'for more details about the many cost efficient services '
+ 'we provide. Samples of digital productions, such '
+ 'as: Web sites; banner ads; and applications are '
+ 'available in our online <a href="portfolio.html">Portfolio</a>.</font></p> '
+ '<p><font face="Arial" size="2">A <a href="contract.html">sample '
+ 'contract</a> is provided to illustrate the lengths '
+ 'L-A WebTek has taken to protect our clients. We have included '
+ 'a list of leading competitors as we invite you to '
+ 'shop around and compare us. L-A WebTek can even '
+ 'give you a free, no-obligation online <a href="estimate.html">estimate</a>.</font></p> '
+ '<p><font face="Arial" size="2">For more information '
+ 'about: the web design process; application development; '
+ 'graphic design; various marketing concepts and productions; '
+ 'and other relevant topics, browse the <a href="resources.html">Resources</a> '
+ 'section of the site.</font></p>'
}

function getC() {
document.getElementById('content').innerHTML='<p><b><font face="Arial" size="2">Standard services '
+ 'are billed at $40.00 per hour.'
+ '</font></b></p><p><font face="Arial" size="2"><b>Layout</b> - The Developer will '
+ 'design the Web page layout and planning with consideration for balance, color, and '
+ 'functionality.</font></p><p><font face="Arial" size="2"><b>HTML Coding</b> - The '
+ 'Developer will create the underlying HTML code, which is accessed by the end-user '
+ 'Web browser to create the basic elements of the Web page. </font></p>'
+ '<p><font face="Arial" size="2"><b>Text Formatting</b> - The Developer will check '
+ 'text for spelling and grammatical accuracy as well as applying font types, sizes, '
+ 'and colors. Formatting also includes the alignment of text within the Web page '
+ 'to produce maximum visibility to the end-user. </font></p>'
+ '<p><font face="Arial" size="2"><b>Cascading Style Sheets (CSS)</b> - The Developer '
+ 'will create CSS, which is either internally embedded or an external file that '
+ 'defines reusable font types, colors, and sizes that can be applied throughout '
+ 'the Web site. These &quot;styles&quot; can be applied to text, hyperlinks, tables, '
+ 'and form elements via the &quot;class&quot; HTML tag. CSS produces uniform page '
+ 'elements with less time spent on update maintenance and shorter, faster loading '
+ 'Web pages.</font> </p>'
}

but nowI am posed with a new problem. If a visitor presses the browser Back button, they will most likely leave my site.
can I use an onUnload event handler and call a function like:

function goHome() {
if(document.location==history(-1)) document.location = history(+1);
}

The above does not work but basically I want to boomarang them back to the index page. Any thought?

LAwebTek
02-12-2003, 10:55 AM
Originally posted by khaki
I tried putting the script into a seperate JS file and the <div> into a HTML file (and referenced the JS file as a source).


I put the code I posted above into a seperate file, scriptC.js, and referenced it in the head:

<script language="JavaScript" type="text/javascript" src="scriptC.js"></script>

and was able to manipulate the div using links whithin the html that called functions in the script.

khaki
02-12-2003, 11:25 AM
Thanks "A guy glued to a PC" - also known as LAwebTek (I'd like to start a campaign to have everybody give us some kind of workable name that we can go by. keep dreaming, right?)

I got it to work (my problem was a spelling error! Gotta keep those function and variable names short and easy! 30 minutes wasted on a transposed a & i. grrrrr)

... and thanks Pyro, my perpetual hero! (with the cool new look)
k

pyro
02-12-2003, 11:34 AM
Originally posted by khaki
... and thanks Pyro, my perpetual hero! (with the cool new look)<grin>

Originally posted by LAwebTek
basically I want to boomarang them back to the index page.You might want to re-think doing this. Don't you think that your users might get a bit annoyed if they can't leave you site by browsing back? I know that I would...