Jump to content

Stack Overflow At Line: 0


heldplayer

Recommended Posts

I am making an imageviewer that loads an image throug the window.location.search but when the image is loaded I get an alert that says:Stack overflow at line: 0window.location.search is ?img=210&year=2007-2008&type=big

function getImage(){var img=window.location.search.substr(1).split("&");var img=image[0].split("=")[1];var year=image[1].split("=")[1];var type=image[2].split("=")[1];var src="../" + year + "/" + type + "/" + img + ".bmp";return src;}

the .bmp is because 1: its curently in my pcand 2: jpg, gif, ... doesn't work

Link to comment
Share on other sites

img and image are not the same,the return value is for setting the <img /> src valuebut the problem is solved, I called the function within the image but if it is in the body then it is ok:bad: <img onload="this.src=getImage()" />good: <body onload="document.getElementById('image').src=getImage()">

Link to comment
Share on other sites

You're also declaring the same variable twice, which isn't a good thing:var img=window.location.search.substr(1).split("&");var img=image[0].split("=")[1];

Link to comment
Share on other sites

You're also declaring the same variable twice, which isn't a good thing:var img=window.location.search.substr(1).split("&");var img=image[0].split("=")[1];
misspelled it, the first img should be image, sorry
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...