• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

open new, smaller browser window

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
jim123052397
Asked:
jim123052397
  • 9
  • 5
  • 2
1 Solution
 
LukeskywalkerCommented:
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
 
webwomanCommented:
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
 
jim123052397Author Commented:
webwoman - if i use your idea, how do i specify the size and location of the new window?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
LukeskywalkerCommented:
<A HREF="javascript:;"onClick="window.open('test.htm','test','width=100,height=500,left=100, top=100'); return false;">open a window</A>
0
 
webwomanCommented:
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
 
jim123052397Author Commented:
thanks - lemme try that over the weekend
0
 
jim123052397Author Commented:
thanks - lemme try that over the weekend
0
 
jim123052397Author Commented:
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
 
webwomanCommented:
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
 
jim123052397Author Commented:
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
 
webwomanCommented:
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
 
jim123052397Author Commented:
i suppose i could load it into a frame like i have seen done on other sites, but i hate frames....
0
 
jim123052397Author Commented:
i suppose i could load it into a frame like i have seen done on other sites, but i hate frames....
0
 
jim123052397Author Commented:
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
 
webwomanCommented:
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
 
jim123052397Author Commented:
wonderwebwoman -

thanks for sticking with this.

take care -
jim
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 9
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now