Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Sep 2009
    Location
    Tamaqua, Pa
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need help with code for image in new window

    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>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,860
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Without seeing a link to your window or your code, I can only give
    Code:
    body{
    background-color:<the required color here >
    }
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Sep 2009
    Location
    Tamaqua, Pa
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That would change the background color of the current page. I would like to specify the color of the target _blank new window

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,860
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Post that code of your new window.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Sep 2009
    Location
    Tamaqua, Pa
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <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>

  • #6
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello crazyjust,
    Have a quick look at why target="_blank" is frowned upon.

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

    Code:
    <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>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #7
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,860
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    <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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •