I am trying to open a larger picture of the original picture that is in the html document. in the html its called "bild.png" and I want to open a larger one called "big_bild.png" in a new window.
I have fetced all the images and sorted out the one I want in another function. the function I cant get to work looks like this:
function visa(){
var pic = this.src; //the original picture called from the other function
var pic1="big_"; //this is what I want to add to the original filename.
var pic2=pic1+pic;
open(pic2); }
when this runs it tries to open to files instead of adding the text "big_" to the orignal file.

I know this is really easy for those who know but I am veery new to javascript and strugeling to understand how to put it all together.
I would be very happy if someone could help me understand what I doing wrong.:?:

7 Years
Discussion Span
Last Post by barjlund

There is a number of ways to do this. Here are a couple:

Rule based (prepend "big_"):

function visa(){
	var imgUrlArray = this.src.split('/');
	imgUrlArray[imgUrlArray.length-1] = 'big_' + imgUrlArray[imgUrlArray.length-1];

Non rule based, with large image url coded as a custom attribute of the img tag:

function visa2(img){

Here's the HTML for use with visa2:

<img src="http://www.daniweb.com/alphaimages/misc/logo/logo.gif" bigSrc="http://www.daniweb.com/alphaimages/misc/navigation/community.gif" border="0" alt="myImage" onclick="visa2(this)">


Edited by Airshow: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.