Closed Thread Icon

Topic awaiting preservation: ' ' " " question. (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=8763" title="Pages that link to Topic awaiting preservation: &amp;#039; &amp;#039; &amp;quot; &amp;quot; question. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: &#039; &#039; &quot; &quot; question. <span class="small">(Page 1 of 1)</span>\

 
Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 07-21-2003 02:09

Hi, guys. How are you?
I'd like to ask very simple but strange stuff.
Please see this code:

code:
leftPos = 0
if (screen) {
leftPos = screen.width-225
}

newWindow = window.open("cpanel.html", "newWin", "width=225,height=200,left="+leftPos+",top=0")



My question is:

Why left="+leftPos+" not '+leftPos+'?
And why do I have to put both + around leftPos???

My history is little hazy.....If Iremember things correctly, I have to use ' instead of " when I nest quotation marks....Am I right? I guess left='+leftPos+', wrong???
Hmm......this script come from here.
Many thanks in advance.
Cya.

Ps. Did you have a good weekend? I did.

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-21-2003 02:27

Don't think of it as "+leftpos+". Think of it like this:

"blah blah blah"
+
leftpos
+
"blah blah blah"

The reason you need to use double quotes is because they have to match up with the opening and closing quotes on the other sides.

Let's say the value of leftPos is 10. Then this:

"width=225,height=200,left="+leftPos+",top=0"

will be the same as:

"width=225,height=200,left=10,top=0"

But this:

"width=225,height=200,left='+leftPos+',top=0"

is still just:

"width=225,height=200,left='+leftPos+',top=0"

In the first case, you end the string (it started with a double quote, so you end it with a double quote), then you concatenate the value of leftPos to it, and then you concatenate another string to it (starting and ending with double quotes). In the second case, the whole thing is one big string, from the opening double quote to the closing double quote.

See, the reason you use double quotes here is because you don't *want* the quotes to be part of the string. You want them to end the string, then you do some concatenation, and then you open up a new string. But if you use single quotes in the middle there, then you only have one single string, and the word "leftPos" is nothing more than a few letters within it.

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 07-21-2003 05:46

Hi, Slime!
I got it!!!

quote:
"blah blah blah"
+
leftpos
+
"blah blah blah"



This makes me clear! Great explanation.
So before +lefttops blash blah blah is width=225,height=200,left= and after lefttops is ,top=0, aren't they?

Many thanks!

Hiroki Kozai

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 07-21-2003 06:43

Yup =)

Hiroki
Paranoid (IV) Inmate

From: NZ
Insane since: Dec 2002

posted posted 07-21-2003 23:30

Hi, Slime.
Many many thanks a lot.
Have a good day.
Cya.

Hiroki Kozai

silence
Maniac (V) Inmate

From: soon to be "the land down under"
Insane since: Jan 2001

posted posted 07-22-2003 06:53

Personally, I like to separate concatenated strings just to be able to read them easier. It's good coding practice.

E.G.:
"this string" + something + "this other string"

Unless, of course, window.open won't let you add whitespace like that.

« BackwardsOnwards »

Show Forum Drop Down Menu