473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Display in new Window

20
I have a problem regarding open the enlarged image in a new window. What I am facing problem is I have to open put the image in the div from Javascript which I have done well and now what I need is when the user clicks on the image the image should be displayed in a new window. I have also tried this by using href option but when I put the window.open function into the href I original page gives an error which i do not want, I want the original page to be intact just opening the image in a new window. Is there any possible way. Here is what i have so far. Please could anyone customize the code so that I can open the image in a new window. Help greatly appreciated.

[HTML]<html>
<body>
<div id="todiv">
<table >
<tr >
<td id="abc"></td>
</tr>

</table>
<a href="javascript:test();">Test</a>
</div>
</body>

<script language="javascript">
function test(){
var image = document.createElement('img');
var a = document.createElement('a');
image.src = 'boating.jpg';
a.id = 'aID';
image.id = 'imageID';
document.getElementById("abc").appendChild(a);
document.getElementById("aID").appendChild(image);

// document.getElementById("hID").href = "javascript:window.open('boating.jpg','','width=60 0,height=500, resizable=yes, scrollbars=yes');"; //--->when i do this the original page gets lost
document.getElementById("aID").href = '#'; // --->done for keeping the original page intact

document.getElementById("aID").onclick = "javascript:window.open('boating.jpg','','width=60 0,height=500, resizable=yes, scrollbars=yes');"; //--->this script is not working

}
</script>

</html>[/HTML]
Mar 11 '08 #1
3 1405
gits
5,390 Expert Mod 4TB
try this:

Expand|Select|Wrap|Line Numbers
  1. var func = function() {
  2.     window.open(
  3.         'boating.jpg','','width=600,height=500,resizable=yes,scrollbars=yes'
  4.     );
  5. };
  6.  
  7. document.getElementById("aID").onclick = func;
  8.  
kind regards
Mar 11 '08 #2
mylog
20
Thank u very much. This worked perfectly.
Mar 12 '08 #3
gits
5,390 Expert Mod 4TB
no problem ;) ... post back to the forum anytime you have more questions ...

kind regards
Mar 12 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Oliver | last post by:
Hello, i'm having trouble with a css type popup. It's not doing what i want in Mozilla 1.6 and in IE6.0 it's not working at all. The html code looks like this: <div class="themenkueche"...
2
by: William Gill | last post by:
I need to display a couple of labels and a checkbox from each entry in my database. Simple enough, but there are several hundred records, and I only want to display 5 or 10 at a time. Can this be...
0
by: Ferry Boender | last post by:
Hi, I'm relatively new to Xlib programming, and I ran into a little problem. I'm trying to insert keypress events into a X window. The following code works: ...
1
by: rajbala.3399 | last post by:
Hai all, I need to get multiple image buttonsand wheni click on the image button it should display corresponding image on window and if i click another image button it is also display on same...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
4
by: ArrK | last post by:
I want to use a control frame to create and/or modify the content (images and text) of a display frame - all files and images are client side. . When I try to write to the display frame from the...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
5
by: wreed06 | last post by:
I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully validated my HTML...
2
by: H. Rodriguez | last post by:
Hello, I would like to be able to open a new IE window on the client side and display a PDF document in the new window. Many tutorial sites that I have checked suggest opening a new IE window...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.