Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I want to pop up a window on my computer from a .htm page. What is the reference and/or syntax?

Posted on 2003-10-30
16
Medium Priority
?
238 Views
Last Modified: 2012-05-04
I have an .htm page open from my local computer.

I can add links to other pages, but I don't know how to create a popup window graphic link from my local computer.

I found this and tried it...

<a href="newwindow.htm" onClick="window.open('samplewindow.htm', 'NewButtonWindowName','width=375,height=250')"><img src="button.gif" alt="AlternateText Description" </a>

I am confused with the references. I am on let's say page1.htm  I want to open page2.htm  page1.htm is in a folder called maintenance and I want to open page2.htm which is in a folder called help, so I think it is ../help/page2.htm I am going to use a button from ../images

What do you think they are asking for in place of newwindow.htm samplewindow.htm and newbuttonwindowname ?

Any help would be appreciated.

0
Comment
Question by:jamesh1031
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +1
16 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9656630
newwindow.htm refers to the page that will be opened on the main browser window when you click the image.

samplewindow.htm refers to the page that will be opened in the popup

NewButtonWindowName looks like it should be the title for the window, but this doesn't show up on Mozilla Firebird.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9656643
Sorry.  Submitted too soon ;-)

In your case, you want to replace 'samplewindow.htm' with ../help/page2.htm.

If you want to remain on the same "main" page in the browser, you can just remove the href="newwindow.htm" to leave <a onClick...
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9656687
If you want lots more detail, see : http://tech.irt.org/articles/js128/index.htm
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Accepted Solution

by:
YZlat earned 2000 total points
ID: 9657282
put this in the <head> section of your page
<script language="JavaScript">

<!--//

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");

}
//-->
</script>

and the code below goes into your <body> section

<a href="javascript:new_window('../help/page2.htm' )"><img src="images/button.jpg"></a>

as for your code,
newwindow.htm  you don't need,
samplewindow.htm is a url of the new window you want to open,
and newbuttonwindowname is a name of your new window(whatever you want to call it)

0
 
LVL 35

Expert Comment

by:YZlat
ID: 9657292
to customize your new window that will pop-up you can modify the code of the javaScript function I posted

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");

}
if you want toolbar on your page, set toolbar=1 instead of 0. also you can change height and width etc.
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9658053
The minimalist version:
<html>
<head>
<script language='javascript' type='text/javascript'>
<!--
function openWin(url)
{
  window.open(url)
}

//-->
</script>
</head>
<body>
<a href="#" onclick="openWin('http://members.aol.com/grassblad')"><img src="http://members.aol.com/grassblad/images/grassAvatar.jpg" alt="GrassBlade Javascript" border="3"></a>
<a href="#" onclick="openWin('http://www.webxpertz.net/forums')"><img src="http://www.webxpertz.net/forums/images/wx/wx_logo.jpg" alt="Webxpertz Forums"></a>
</body>
</html>
Vinny
0
 

Author Comment

by:jamesh1031
ID: 9659456
I put this in Head section:

<script language="JavaScript">

<!--//

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");

}
//-->
</script>

I put this in the body:

 <a onclick="javascript:new_window('../help/help_related_scacs.htm' )"><img src="../images/SpacersIconsSquaresGraphics/squareoutline2.gif"></a>

a window the right size opens, but i get a "Cannot find server" "The page cannot be displayed" message.

I tried with an exact path c:/etc.... but that didn't make a difference.

Any help would be appreciated. Thank you.



0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9659505
since the following works:
 <a onclick= "javascript:new_window('http://members.aol.com/grassblad' )">....

i would have to say:
1) there is a typo in path/filename
2) the file and/or folders/directories do not exist

Vinny
0
 

Author Comment

by:jamesh1031
ID: 9659661
this page is not at a http: address, which may be the issue...

I can open the page as a regular link, I just can't get it to be a pop up.....
0
 

Author Comment

by:jamesh1031
ID: 9659674
Does it matter that I am in a frames page?
0
 

Author Comment

by:jamesh1031
ID: 9659836
I put everything in one folder, the page I am in, the page I want to open....still can't find it...
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9659860
you can get it to open as a link? but not a popup?  can I see your code?
did you try my version? first as is, then in your page, finally with your data.

Vinny
0
 

Author Comment

by:jamesh1031
ID: 9663336
Your code with the http: works fine.

So, I changed the line to:

 <a href="#" onclick="openWin('../help/help_related_scacs.htm')">

and it can't find the page. The explorer address window shows a path on my computer:

C:\Documents and Settings\XXX\Local Settings\Temporary Internet Files\help\help_related_scacs.htm

So, as I said in the beginning : how to create a popup window graphic link from my local computer? , the local computer path is an issue with the java script.

Regular links like this one: <a target="main" href="../MaintenancePages/MaintainTrailerSCACwReports.htm"> work fine.


0
 

Author Comment

by:jamesh1031
ID: 9663352
Do I have to have script tags in the body also?
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9663733
Sorry, I just realized you may not be using IE.

<a href="file:c://Document......"

note the two "//"

Vinny
0
 

Author Comment

by:jamesh1031
ID: 9664370
This is now working, the only difference was the direction of the slashes. Help/Help_Related_Scacs.htm'

Head:

 <script language="JavaScript">

<!--//

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=500,left=40,top=50");

}
//-->
</script>

Body

<a  onclick="javascript:new_window('../Help/Help_Related_Scacs.htm')">
        <img src="../images/SpacersIconsSquaresGraphics/squareoutline2.gif" align="right"></a>
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question