Reputation: 629
i have a function,
function showimage(a)
{
$("#lightboxholder").show("fast");
$('#lightboximage').attr('src', 'images/demo/190x90.gif');
}
when i go to localhost/svce and view in gallery.php, it doesnt show me the image, however if i replace $('#lightboximage').attr('src', 'images/demo/190x90.gif');
by $('#lightboximage').attr('src', 'http://localhost/svce/images/demo/190x90.gif');
then it shows me the image, sorry for my bad english, thanks
Upvotes: 1
Views: 243
Reputation: 71939
You're changing the src
to a relative URL. So if your current page is http://localhost/foo/bar
, the browser will try to find the image at http://localhost/foo/bar/images/demo/190x90.gif
. Use an absolute URL, like /svce/images/demo/190x90.gif
.
Upvotes: 1
Reputation: 26396
The problem is relative url - it's always a challenge for me too
Try these
$('#lightboximage').attr('src', '../images/demo/190x90.gif');
or
$('#lightboximage').attr('src', '../../images/demo/190x90.gif');
As you move from page to page, relative url will change, but absolute won't
Upvotes: 1
Reputation: 8911
Try
function showimage(a)
{
$("#lightboxholder").show("fast");
$('#lightboximage').attr('src', '../images/demo/190x90.gif');
}
Note the "/" before images/demo....
Upvotes: 1