?
Solved

open new, smaller browser window

Posted on 2003-02-18
16
Medium Priority
?
207 Views
Last Modified: 2010-04-25
I'm using Dreamweaver 3, and would like external links (whether from images or text) to open in a new, smaller browser window, leaving the original window and page just as they are.

When I use Behaviors to specify the smaller window, but don't specify the link in the Properties window, the cursor does not change to a "hand" and the text is not underlined to show the users that it is a link.

When I use the Properties window to specify the link (with target="blank"), and then use Behaviors to specify the Open Browser Window specs, both the new AND the original windows go to the new Web page.  I can correct this by also using Behaviors' Go to URL function and specifying the original page (it then just reload itself), but this doesn;t work well for changing these links when they occur on multiple pages of the site (as in the nav section)...the Go to URL has to be specific to each page.

Is there an easy way to accomplish this?

And is there a way to specify the location of the new window (i.e., 70 pixels down from the top of the screen and 70 pixels in from the left)?

Thanks -
Jim
0
Comment
Question by:jim123052397
[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
  • 9
  • 5
  • 2
16 Comments
 

Expert Comment

by:Lukeskywalker
ID: 7983049
I usually write my own scripts.....try this...


<script language="JavaScript">

function newWin() {
 newWindow = window.open('mypage.htm', 'Win', 'width=350, height=350, left=70, top=70')
}

</script>


<a href="javascript:newWin()">Open my new window</a>

Left=70 and top=70 will put the window 70 pixles from the left and 70 from the top.
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7983997
I wouldn't do it quite that way... I'd do the link like this.

<a href="#" onclick="newWin();return false">Open new window</a>

That way the window opens but you don't get anything happening in the main browser window.
0
 

Author Comment

by:jim123052397
ID: 7988563
webwoman - if i use your idea, how do i specify the size and location of the new window?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Expert Comment

by:Lukeskywalker
ID: 7989704
<A HREF="javascript:;"onClick="window.open('test.htm','test','width=100,height=500,left=100, top=100'); return false;">open a window</A>
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7995534
You still have it wrong...
It's much easier to write a function (like you did before), you don't use javascript in the href, and you're missing a space (the space might not make a difference).

jim123, you can specify the size in a few different ways. I pass it to the function, then I can reuse the function anyplace I want and still control the size of the window.

Like this...
<script language="JavaScript">
function MakeNewWindow(theURL,h,w) {
 var opts="resizable,toolbar=no,menubar=no,scrollbars=yes,width="+w+",height="+h;
var newWindow=window.open(theURL,"",opts);
}

</script>

Called like this...
<a href="#" onclick="MakeNewWindow('show_page.html','300','300');return false">link text</a>

Always works for me -- for just about every browser.
0
 

Author Comment

by:jim123052397
ID: 7996683
thanks - lemme try that over the weekend
0
 

Author Comment

by:jim123052397
ID: 7996685
thanks - lemme try that over the weekend
0
 

Author Comment

by:jim123052397
ID: 7996698
oops - i see how your are specifying the size of the windowm but not the position.  i want it be 60 pixels in from the left and 60 pixels down from the top
0
 
LVL 19

Expert Comment

by:webwoman
ID: 7999182
You do that in the actual page -- the window will open, then move to where you want.

<body onload="moveTo(60,60)">

That should work.
0
 

Author Comment

by:jim123052397
ID: 8003231
these will be links for EXTERNAL sites - not to pages from our own web site, but to other web sites' pages, where i cannot control the HTML code.  i want the external page (in the new window) to open 60 down and 60 over, to still allow the familiar logo and left nav column to be a bit visible.  

and just so i understand your script, what does the "#" represent when i enter the following?
<a href="#" onclick="MakeNewWindow('show_page.html','300','300');return false">link text</a>
is that just so the original page "stays put"?

- jim
0
 
LVL 19

Expert Comment

by:webwoman
ID: 8003824
Yes. It's a dummy link, so that you don't actually load anything, and the 'return false' keeps it from even reloading the page.

I'm not sure if you can specify the location of the window when you open it. If the new window is named, you should be able to move it. I'll have to check around and see.
0
 

Author Comment

by:jim123052397
ID: 8003846
i suppose i could load it into a frame like i have seen done on other sites, but i hate frames....
0
 

Author Comment

by:jim123052397
ID: 8003847
i suppose i could load it into a frame like i have seen done on other sites, but i hate frames....
0
 

Author Comment

by:jim123052397
ID: 8094206
hi -

i implemented your script language, as best i could, in this page:
http://mgiwebnet.millard.com/mgistagingweb/new-industry-events-new.html

but when i click on the links in netscape, nothing happens.  in internet explorer, i get a script error:
"Microsoft JScript compilation error:
Line:     11
Char:    108
Error:   Unterminated string constant".

Then, when I override that and load the page, I get this error:
"Microsoft JScript compilation error:
Line:    
Char:    
Error:   Object expected".
0
 
LVL 19

Accepted Solution

by:
webwoman earned 600 total points
ID: 8094569
It's here...
Error: unterminated string literal
Source File: http://mgiwebnet.millard.com/mgistagingweb/new-industry-events-new.html
Line: 11, Column: 9
Source Code:
var opts="toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=650,height=350;

You don't have the closing " -- it goes before the ;

Fix that and it should work fine.

Javascript is picky. If you use Netscape/Mozilla to check, you can use the javascript debugging console that's built in to find out exactly what the problem is.
0
 

Author Comment

by:jim123052397
ID: 8095888
wonderwebwoman -

thanks for sticking with this.

take care -
jim
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

741 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