Hi there,
I've just began to learn javascript myself, and I've got lots of problems. The biggest problem however concerns the changing of a backgroundimage.
I know how to change a background image in the same window, but I can't figure out how to do it out of another window. Basically it comes down to this:
I have a bunch of imagefilelinks, and if I click them, a new window pops open with in it the enlarged picture. On the bottom of that window there are two buttons: one to close the window and another intending to change the backgroundimage of the 'parent' window.
The latter isn't working however.
function openPicture(theURL,winName,features) {
var picture_window = window.open(theURL,winName,features);
picture_window.focus();
picture_window.document.write("<html>");
picture_window.document.write("<body>");
picture_window.document.write("<img src='' name='image' height='400' width='400'>");
picture_window.document.image.src= theURL;
picture_window.document.write("<form> <input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/Make Background' onClick='changeBackground("'theURL'")'</form>")
//to avoid confusion: this is the same 'theURL' as in openpicutre(...)
picture_window.document.write("<form> <input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/Close Window' onClick='window.close()'</form>");
picture_window.document.write("</body>");
picture_window.document.write("</html>");
}
function changeBackground(picture) {
parent.document.body.="'picture'";
}
As you can see, I've copied the code. Can someone tell me what I'm doing wrong?
Thanks a lot.
K
I've just began to learn javascript myself, and I've got lots of problems. The biggest problem however concerns the changing of a backgroundimage.
I know how to change a background image in the same window, but I can't figure out how to do it out of another window. Basically it comes down to this:
I have a bunch of imagefilelinks, and if I click them, a new window pops open with in it the enlarged picture. On the bottom of that window there are two buttons: one to close the window and another intending to change the backgroundimage of the 'parent' window.
The latter isn't working however.
function openPicture(theURL,winName,features) {
var picture_window = window.open(theURL,winName,features);
picture_window.focus();
picture_window.document.write("<html>");
picture_window.document.write("<body>");
picture_window.document.write("<img src='' name='image' height='400' width='400'>");
picture_window.document.image.src= theURL;
picture_window.document.write("<form> <input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/Make Background' onClick='changeBackground("'theURL'")'</form>")
//to avoid confusion: this is the same 'theURL' as in openpicutre(...)
picture_window.document.write("<form> <input type='button' value='http://www.webdeveloper.com/forum/archive/index.php/Close Window' onClick='window.close()'</form>");
picture_window.document.write("</body>");
picture_window.document.write("</html>");
}
function changeBackground(picture) {
parent.document.body.="'picture'";
}
As you can see, I've copied the code. Can someone tell me what I'm doing wrong?
Thanks a lot.
K