6 Replies - 1210 Views - Last Post: 13 December 2002 - 02:32 PM

#1 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

stupid javascript

Posted 10 December 2002 - 10:04 AM

ok, i have an image being randomly generated through asp. i then pass the image path and alt to javascript like so:

var imgPath = <%=objRS("path")%>;
var imgAlt = <%=objRS("alt")%>;

and that comes out fine. but the second thing i want to do is to adjust the image size based on window size, so i have a pre-written width detector thing. so THEN I do this:

var imgPath = <%=objRS("path")%>;
var imgAlt = <%=objRS("alt")%>;
if (Width <= 1000) {
	document.write("<img src='/images/level1/" + imgPath + "' vspace='20' alt='" + imgAlt + "' width='760'>");
	}
else {
	document.write("<img src='/images/level1/" + imgPath + "' vspace='20' alt='" + imgAlt + "' width='975'>");
	}



but no image shows. what am i doing wrong?
the image path and alt are coming through correctly, but the image tag isn't working.

:)

Is This A Good Question/Topic? 0
  • +

Replies To: stupid javascript

#2 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: stupid javascript

Posted 10 December 2002 - 10:16 AM

i added quotes around the asp variables coming in, but still no luck.
Was This Post Helpful? 0
  • +
  • -

#3 Koenie  Icon User is offline

  • What?!

Reputation: 0
  • View blog
  • Posts: 1,313
  • Joined: 08-July 02

Re: stupid javascript

Posted 10 December 2002 - 12:28 PM

what's with the 'Width <= 1000'? What does it mean?
Was This Post Helpful? 0
  • +
  • -

#4 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: stupid javascript

Posted 10 December 2002 - 12:41 PM

the Width was coming from another script which determines the width of the browser window, so if the browser window was smaller I wanted the image to be smaller...

believe it or not, I fixed the problem by simply moving everything out of the head and into the body... stupid javascript...
Was This Post Helpful? 0
  • +
  • -

#5 Koenie  Icon User is offline

  • What?!

Reputation: 0
  • View blog
  • Posts: 1,313
  • Joined: 08-July 02

Re: stupid javascript

Posted 10 December 2002 - 12:51 PM

klewlis, on Dec 10 2002, 10:41 PM, said:

stupid javascript...

Watch out with calling Javascript names.......
Was This Post Helpful? 0
  • +
  • -

#6 gneato  Icon User is offline

  • <title>Untitled Document</title>

Reputation: 0
  • View blog
  • Posts: 1,311
  • Joined: 03-September 01

Re: stupid javascript

Posted 10 December 2002 - 01:07 PM

I believe the problem may have been that you were trying to document.write in the <head>.
Was This Post Helpful? 0
  • +
  • -

#7 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: stupid javascript

Posted 13 December 2002 - 02:32 PM

no, I wasn't document.write-ing in the head... the snippet I showed above was always in the body... but the part that determined the width and height of the window was in the head... must have been a variable scope thing, having it defined in the head and then using it in the body... I moved all the head stuff to the body and now it works!

(I hate javascript. Was there ever a more finicky "language"?)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1