|
-
Jan 11th, 2006, 08:09 AM
#1
Thread Starter
New Member
Javascript trigger after loading image?
I'm having problems with this source code.
I am loading a image from a SQL server. When the image is loaded, the window (opener window -> little) should be the size of the image. I want to trigger a javascript script after the asp.Net code. How do I do this:
Code:
If type = 1 then
image1.imageUrl = lookforimage(imageNr)
I WANT TO TRIGGER THE JAVASCRIPT HERE ? BUT HOW?
-
Jan 12th, 2006, 02:39 AM
#2
Thread Starter
New Member
Re: Javascript trigger after loading image?
Can't anybody help me with this?
-
Jan 12th, 2006, 03:05 AM
#3
New Member
Re: Javascript trigger after loading image?
from your code behind?
like this work for me:
Code:
string popupScript = "<script language='javascript'>" +
"var x=screen.width;" +
"var y=screen.height;" +
"x=x-80;" +
"y=y-100;" +
"window.open('http://www.google.com', 'CustomPopUp', " +
"'Height=' + y + ',Width=' + x +', resizable=no,scrollbars=yes,titlebar=no,status=1,toolbar=no,Left=0,top=0')" +
"</script>";
Response.Write(popupScript);
so it's just a javascript string, and you do a response.write
-
Jan 12th, 2006, 05:56 AM
#4
Thread Starter
New Member
Re: Javascript trigger after loading image?
Thanx for responding VanPetrol,
But this code just add's a function in the window. I want to trigger it so the window is resized 'after' the image is loaded. I put the code below:
image1.ImageUrl = lookfortheimage(imageNr)
Dim sb as String
sb = "<scr" + "ipt language=javascript>"
sb+= "function window_res() { "
sb+= "var imgW = window.Form1.image1.witdh; "
sb+= "var imgH = window.Form1.image1.height; "
sb+= "window.self.parent.resizeTo(100, 200); "
sb+= "}</scr" + "ipt>"
Response.Write(sb)
When I do this the window will not resize :S
-
Jan 12th, 2006, 06:05 AM
#5
Re: Javascript trigger after loading image?
Place the code for resizing in the body's onload event.
-
Jan 12th, 2006, 06:55 AM
#6
Thread Starter
New Member
Re: Javascript trigger after loading image?
Dear mendhak,
I did this with body onload event, but when the page is visible it is busy with loading a image from the sql server. With the body onload event it sometimes can't find the width of the image because it loads from the db. Then the javascript comes with undifined witdh wich means the image was not loaded. That's the reason that the trigger must done after the image is loaded. Any suggestions?
-
Jan 12th, 2006, 09:48 AM
#7
Re: Javascript trigger after loading image?
Don't use Response.Write(sb)
Use Page.RegisterClientScriptBlock for your sb, then call it by using Page.RegisterStartupScript to call the function.
-
Jan 13th, 2006, 02:28 AM
#8
Thread Starter
New Member
Re: Javascript trigger after loading image?
mendak,
When I use your sugg. about the scripting the @#!)(@*# javascript still doesn't trigger. I use the folowing script, why doesn't it still trigger?
Code:
Dim sb as String
sb = "<script language='javascript'>function window_res() { window.self.parent.resizeTo(100, 200); }</scrip " & "t>"
image1.ImageUrl = GoAndFindTheImageFromSQL(imageNr)
Page.RegisterClientScriptBlock("script", sb)
Page.RegisterStartupScript("script", sb)
-
Jan 13th, 2006, 09:04 AM
#9
Re: Javascript trigger after loading image?
Try backtracking.
Try to get the page to do a simple alert() in javascript. Is that working?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|