Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Coding problem

Reply
Thread Tools

Coding problem

 
 
meagain
Guest
Posts: n/a
 
      08-27-2013
Robert Baer wrote:
> Hot-Text wrote:
>> "Robert Baer" <(E-Mail Removed)> wrote in message
>> news:dltSt.150347$(E-Mail Removed)...
>>> Robert Baer wrote:
>>>> Doug Miller wrote:
>>>>> Robert Baer<(E-Mail Removed)> wrote in
>>>>> newsptRt.321878$(E-Mail Removed):
>>>>>> The following code "works" in a strange way; see the comments for
>>>>>> details.
>>>>>> 1) why is that document.write necessary for operation?
>>>>>> 2) why doesn't the altered variable "title" remain changed?
>>>>>> 3) i would like to change displayed page, based on map visits
>>>>>> Help? Comments?
>>>>> You'll probably have better luck posting in one of the javascript
>>>>> groups.
>>>> I have found only one JS group, and it is essentially dead.
>>>> Hopefully, http://www.codingforums.com can help.
>>>> Thanks.
>>> Well, if i can only figure out how to POST after the preview...
>>> Anyone have a clue?
>>>

>>
>> Same more info for
>> < http://www.freewebmasterhelp.com/tutorials/javascript >

> Wow! Nicely done, good presentation, nice examples.
> Tanks a lot!!
>


It is good, but does not directly answer the Original question
"why is document.write necessary."

Examine some javascript code, like
document.write(
"<div>"+Date().toLocaleString().substr(0,10).fonts ize(6).bold()+txt.fontsize(6).bold()+"<br><br><\/div>"
);

- http://96.9.49.162/AccessBolton_files/NowPlaying.htm

and you should see why it is "necessary."
 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      08-27-2013
meagain wrote:

>> > Robert Baer wrote:

> Hot-Text wrote:



>>> Same more info for
>>> < http://www.freewebmasterhelp.com/tutorials/javascript >

>> Wow! Nicely done, good presentation, nice examples.
>> Tanks a lot!!
>>


The above link is obsolete at best, recommending such things as HTML
comments in script elements to "hide script from old browsers". Really?
If memory serves me wasn't that a version of Netscape 2?

>
> It is good, but does not directly answer the Original question
> "why is document.write necessary."
>
> Examine some javascript code, like
> document.write(
> "<div>"+Date().toLocaleString().substr(0,10).fonts ize(6).bold()+txt.fontsize(6).bold()+"<br><br><\/div>"
> );
>
> - http://96.9.49.162/AccessBolton_files/NowPlaying.htm
>
> and you should see why it is "necessary."


"necessary"? The main problem with document.write is that it must be
done BEFORE the document finishes loading whereas using DOM you can add,
remove, and modify elements after the document loads.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
Robert Baer
Guest
Posts: n/a
 
      08-28-2013
meagain wrote:
> Robert Baer wrote:
>> Hot-Text wrote:
>>> "Robert Baer" <(E-Mail Removed)> wrote in message
>>> news:dltSt.150347$(E-Mail Removed)...
>>>> Robert Baer wrote:
>>>>> Doug Miller wrote:
>>>>>> Robert Baer<(E-Mail Removed)> wrote in
>>>>>> newsptRt.321878$(E-Mail Removed):
>>>>>>> The following code "works" in a strange way; see the comments for
>>>>>>> details.
>>>>>>> 1) why is that document.write necessary for operation?
>>>>>>> 2) why doesn't the altered variable "title" remain changed?
>>>>>>> 3) i would like to change displayed page, based on map visits
>>>>>>> Help? Comments?
>>>>>> You'll probably have better luck posting in one of the javascript
>>>>>> groups.
>>>>> I have found only one JS group, and it is essentially dead.
>>>>> Hopefully, http://www.codingforums.com can help.
>>>>> Thanks.
>>>> Well, if i can only figure out how to POST after the preview...
>>>> Anyone have a clue?
>>>>
>>>
>>> Same more info for
>>> < http://www.freewebmasterhelp.com/tutorials/javascript >

>> Wow! Nicely done, good presentation, nice examples.
>> Tanks a lot!!
>>

>
> It is good, but does not directly answer the Original question
> "why is document.write necessary."
>
> Examine some javascript code, like
> document.write(
> "<div>"+Date().toLocaleString().substr(0,10).fonts ize(6).bold()+txt.fontsize(6).bold()+"<br><br><\/div>"
> );
>
> - http://96.9.49.162/AccessBolton_files/NowPlaying.htm
>
> and you should see why it is "necessary."

Finally found an un-documented trick by using
document.getElementById() "backwards".
Do not need document.write anywhere.
Am cycling pictures forward or backwards according to onMouseover
visits at 2 designated places.
Code:
<script type="text/javascript">
function incrPage(dir,title)
{
var num=+title.substr(16,1).valueOf();
if (dir===-1)
{
num=num-1;
if (num===0) {num=7;}
}
else
{
num=num+1;
if (num===8) {num=1;}
}
title=title.substr(0,16)+num+title.substr(17);
return title;
// Sequence is 1,2,,7,1 for plus, 1,7,6,,1 for minus
}

function SwPage(updn) {
var Pnam=document.getElementById("imgpage").src;
// above gives full URL, so must parse
var NamLoc=Pnam.search("images");
var ISnam=Pnam.substr(NamLoc);
var NUpg="";
if (updn ==="up") {
NUpg=incrPage(1,ISnam);
document.getElementById("imgpage").src = NUpg;
}
else {
NUpg=incrPage(-1,ISnam);
document.getElementById("imgpage").src = NUpg;
}
}
</script>
 
Reply With Quote
 
Tim Streater
Guest
Posts: n/a
 
      08-28-2013
In article <pgeTt.73700$(E-Mail Removed)>,
Robert Baer <(E-Mail Removed)> wrote:

[snip]

> Finally found an un-documented trick by using
> document.getElementById() "backwards".


[snip]

> document.getElementById("imgpage").src = NUpg;


if you're referring to this, it's not a trick and it's not
"undocumented", it's SOP.

It's the same as doing this:

ptr = document.getElementById("imgpage");
ptr.scr = NUpg;

just that with what you wrote you get a pointer to the element when you
need it rather than ahead of time. There is some optimisation advantage
to my code if you are going to use this pointer lots of times.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
coding problem or player problem? richard HTML 13 04-24-2012 06:56 PM
Coding problem (beginner question) smu VHDL 3 06-28-2006 05:13 AM
general coding issues - coding style... calmar Python 11 02-21-2006 10:36 AM
Problem with coding Bart Schelkens ASP .Net 1 07-29-2004 07:13 PM
simple jsp coding problem Jason Java 1 09-08-2003 07:49 AM



Advertisments