...

View Full Version : need help with code for image in new window



crazyjust
12-28-2009, 04:18 PM
I have this code to show a pic in a new window, but I was curious if its possible to change the background color of the new window that the image is in. The code i'm using is

<a href='/images/pic.jpg' target='_blank' title='Click to enlarge in a new window'><img src='/images/pic.jpg' width=100 height=100 border=0></a>

abduraooft
12-28-2009, 04:20 PM
Without seeing a link to your window or your code, I can only give

body{
background-color:<the required color here >
}

crazyjust
12-28-2009, 04:25 PM
That would change the background color of the current page. I would like to specify the color of the target _blank new window

abduraooft
12-28-2009, 04:58 PM
Post that code of your new window.

crazyjust
12-28-2009, 05:04 PM
<td><a href='/images/pic.jpg' target='_blank' title='Click to enlarge in a new window'>
<img src='/images/pic.jpg' width=100 height=100 border=o></a></div>
<br>pic1</td>

Excavator
12-28-2009, 05:09 PM
Hello crazyjust,
Have a quick look at why target="_blank" is frowned upon (http://www.trilithium.com/johan/2005/03/target-blank/).

I'm no js expert at all, a few seconds with google turned this up:


<head>
<script type="text/javascript">
function showPic(it) {
var w = window.open("","","height=260,width=340,resizable=1,scrollbars=0,status=0,menubar=0,top=0,left=0");
w.document.writeln("<body bgcolor='#587C68'>");
w.document.writeln("<img src='" + it + "'>");
w.document.writeln("<\/body>");
w.document.close();
}
</script>
</head>
<body>
...
<a href="picture.jpg" target="_blank" onclick="showPic(this.href);return false">link</a>
...
</body>

abduraooft
12-28-2009, 05:11 PM
<td><a href='/images/pic.jpg' target='_blank' title='Click to enlarge in a new window'>
<img src='/images/pic.jpg' width=100 height=100 border=o></a></div>
<br>pic1</td>Um.. instead of linking directly to that image, make a serverside page(PHP) and pass the name of that image via url. In that php page write the code to echo the <img> tag dynamically,depending upon the parameter in the url, and then apply the required styles in that page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum