Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Newbie:Quote nesting driving me nuts!

Reply
Thread Tools

Newbie:Quote nesting driving me nuts!

 
 
Patrick
Guest
Posts: n/a
 
      10-05-2003
Hi

I have been on this little problem for quite a while and i have enough
trying to figure it out.I escaped from the left from the right and in
between, using single and double quotes to no avail, it's got me beat.
I am trying to add the link "color" to a child window (Done) and when
i place my mouse on color, the child window color changes (Not done).
It's annoying me because it looks like an easy fix.

Here is the code:

<SCRIPT TYPE="Text/javascript">
NewWindow = window.open('New.html','',"WIDTH=300 HEIGHTS='200'");
NewWindow.document.write("<A
HREF='#'onMouseOver=\"NewWindow.document.bgColor=' #ff0000'\">Color</A>")//not
working
</SCRIPT>

Thanks a lot

Patrick

 
Reply With Quote
 
 
 
 
Patrick
Guest
Posts: n/a
 
      10-07-2003
> First problem, and maybe a typo, is you have no space between HREF="#" and
> onMouseOver. The simplest way to "escape" something is to write it as if you
> were hardcoding it, use ", and then wrap it with ' and you are finished. If the
> code contains ', then escape it.
>
> NewWindow.document.write('<A
> HREF="#' onMouseOver="NewWindow.document.bgColor=\'#ff0000\ '">Color</a>');
>
> The second problem is you are making the bgColor change harder than it is. If
> the link is in the NewWindow, then document.bgColor will suffice, since its
> already running from that window. The line then becomes:
>
> NewWindow.document.write('<A
> HREF="#' onMouseOver="document.bgColor=\' #ff0000\' ">Color</a>');


Hi Randy

Thanks a lot for taking the time to help me.Unfortunately your fix
does not seem to work.I use the coda editor which highlights parts of
the code when something is wrong and onMouseOver is highlighted along
with the closing </A> tag (I pasted your corrected code in my editor.)
I also do not understand your escaping technique (i.e. HREF="#').
I hope you can help some more.

Thanks a lot for your time

Patrick
 
Reply With Quote
 
 
 
 
Patrick
Guest
Posts: n/a
 
      10-07-2003
> The second problem is you are making the bgColor change harder than it is. If
> the link is in the NewWindow, then document.bgColor will suffice, since its
> already running from that window. The line then becomes:
>
> NewWindow.document.write('<A
> HREF="#' onMouseOver="document.bgColor=\' #ff0000\' ">Color</a>');


Randy

Disregard my previous post, i figured it out.You had a typo in the
HREF="#'.
My quote nesting must have been good several times originally, what
was really wrong was the NewWindow being referenced twice.Thanks so
much for pointing this out.I still find it strange that referencing
the NewWindow a second time by mistake would prevent the code from
working but anyway i know to be carefull now in the future.

Thanks again

Patrick
 
Reply With Quote
 
Patrick
Guest
Posts: n/a
 
      10-08-2003
> The reason you can't reference it the second time is that in the new window,
> there is no reference given to newWindow, so its an undefined variable. And you
> are writing the link to the new window, so, it doesn't work. Glad you got it
> fixed though.


Randy

I got this too.It makes so much sense now!

Thanks so much

Patrick
 
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
Module.nesting -> Kernel#nesting Trans Ruby 10 09-16-2005 12:21 AM
group nesting David K MCSE 6 12-12-2003 04:54 PM
Nesting Datagrids Edward ASP .Net 3 11-11-2003 09:22 PM
Nesting Datagrids John ASP .Net 0 11-11-2003 04:49 PM
Nesting object tags in ASP 3.0, ASP.NET & Internet Explorer DeadlyTedly ASP .Net 2 10-16-2003 08:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57