Computing.Net > Forums > Web Development > Image index in javascript

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Image index in javascript

Reply to Message Icon

Name: geoshrad
Date: September 24, 2007 at 09:48:20 Pacific
OS: Win XP
CPU/Ram: Pentium
Product: Web
Comment:

When i use an event handler in javascript, i will be able to get the name of the image by using event.srcElement.

But this method does not work in firefox.

What is the alternate method to get the name or index of the image in firefox for a an event.

Thanks in advane
George Joseph

www.geoshrad.com



Sponsored Link
Ads by Google

Response Number 1
Name: mie2com
Date: September 25, 2007 at 16:28:28 Pacific
Reply:

I'm not sure if this is what you're looking for. But it should get the image src.

[script type="text/javascript"]
function getName() {
myAlert = document.getElementById('myImage').src;
alert(myAlert);
}
[/script]

[img id="myImage" src="http://www.http://computing.net/img/runtime.gif"/]
[span onclick="getName();"]Click Me[/span]


0

Response Number 2
Name: geoshrad
Date: September 26, 2007 at 12:47:40 Pacific
Reply:

I got the solution.

I must use to following code to get it

var element = evt.target || window.event.srcElement;

that was the only thing which i ws looking for


function openWindow(url, evt) {
//popupWin = window.open(url, name, 'scrollbars,resizable,width=850,height=700');
//alert("hallo");
var element = evt.target || window.event.srcElement;
//alert(element.src);
//create a new div and include the image there
if( element.width<600)
{
//alert(evt.target);
element.width=600;
element.style.position="absolute";
var file=element.src.indexOf("thumps");
var path=element.src.substring(0,file);
var name=element.src.substring(file+7,file+14);
element.src=path+name;
//element.refresh;
}
else
{
element.width=200;
element.style.position="static";
}

}


www.geoshrad.com


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Image index in javascript

Images in Javascript with http:// l www.computing.net/answers/webdevel/images-in-javascript-with-http-l/534.html

WEBSITE TITLE index IN SEARCH www.computing.net/answers/webdevel/website-title-index-in-search/2828.html

background image wrapping in cell www.computing.net/answers/webdevel/background-image-wrapping-in-cell/1964.html