hot spot links to popup

B

bubipoo

hi guys,
i have a pic that i have created hot spots on. i want these to
open popups with limited features (eg: no status, no resizable...) any
ideas?

darren
 
K

Knud Gert Ellentoft

bubipoo said:
i have a pic that i have created hot spots on. i want these to
open popups with limited features (eg: no status, no resizable...) any
ideas?

In <head>:
<script LANGUAGE="JavaScript">
<!-- Begin
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
// End -->
</script>

and on the hotspot:

<area SHAPE=RECT COORDS="216,154,414,296" HREF="1.htm"
ALT="Billede 1"
onclick="NewWindow(this.href,'link','566','400','no');return
false;" OnMouseOut="window.status=''; return true"
onMouseOver="window.status=''; return true"
onfocus="this.blur()">

You can see it on
http://home13.inet.tele.dk/smedpark/webhjaelp/popup/popup6.htm
(The page is in danish, but look at the source code).
 
R

Richard Cornford

bubipoo said:
i have a pic that i have created hot spots on. i want these
to open popups with limited features (eg: no status, no
resizable...) any ideas?

AREA tags support onclick attributes.

You may want to open windows, and specify chrome for them. If the user
doesn't want that to happen they can prevent it. Years of pop-up abuse
have bought use to the point where trying to open a new window with
JavaScript is so error prone and unpredictable that it is not even worth
attempting unless the contents of that window are totally trivial and
unimportant (in which case why bother?). Better to design web sites to
operate within the one window and leave branching into additional window
up to the user (via, say, the context menu). The alternative is so
chaotic these days that the plethora of possible outcomes could hardly
be considered as "designed".

Richard.
 
L

Lasse Reichstein Nielsen

Knud Gert Ellentoft said:
In <head>:
<script LANGUAGE="JavaScript">

<script type="text/javascript">
The language attribute is deprecated, and the type attribute is mandatory,
in HTML 4.
<!-- Begin

HTML comments are not necessary in Javascript.
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops =
'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'

It is worth mentioning that you try to center the new window wrt. the
screen. It will, ofcourse, fail in, e.g., Opera's MDI mode or in browsers
that open new windows in new tabs (e.g., Mozilla in some setups and MyIE2).

It will also look horrible on two-monitor setups, where it will probably
be placed right on the split.
<URL:http://david.us-lot.org/www/dumb/fullscreen.jpeg>

I would use screen.availWidth and screen.availHeight. It won't make
much difference in practice, but I am suggesting to Opera that they
change the availWidth/Height to the size of the MDI window ... because
it would make sense.

Make winprops a local variable too.
win = window.open(mypage, myname, winprops)

If you don't use the "win" variable outside the function, make it a
local variable.
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

Better:
if (win.focus) {win.focus();}
}
// End -->

Not necessary either.
</script>

I also recommend against depending on new windows.
/L
 
R

Richard Cornford

If you don't use the "win" variable outside the function,
make it a local variable.

As there are a number of JavaScript capable browsers that do not have a
window.open function I would additionally like to see the above line
wrapped in appropriate tests. Else it will generate an error and deprive
the script the option of controlled fall-back. An - if(window.open) -
test seems like a good starting point, except that Pocket IE apparently
lacks a global 'window' property so even that test will error ("window
is null or not an object!, though Pocket IE does not report errors by
default).

The fall-back for a browser without a window.open function should be
navigation within the same window, so the user can get to see the
content. To achieve that the AREA tag could become:-

<area SHAPE=RECT COORDS="216,154,414,296" HREF="1.htm"
ALT="Billede 1"
onclick="return NewWindow(this.href,'link','566','400','no');">

- and the - NewWindow - function could return false to cancel the
navigation and return true to allow the fall-back of navigating within
the current window when the call to window.open is not possible.
However, If you start providing fall-back it becomes worth while to
check the object returned from the call to window.open to ensure that it
has not been influenced by browser settings, content
inserting/re-writing proxies or external pop-up blocking software.
Unfortunately a full battery of tests to cover all of those
possibilities has not yet been written (and is widely believed to be
impossible). Those tests might include:-

if((!win)||(win.closed){
// window has already been squashed by browser settings
// or an external pop-up blocker.
}else{
// window may yet be squashed by external pop-up blocker.
}

if(win == window){
// Proximatron default pop-up blocking filter or similar
// content inserting/re-writing proxy.
}

//and so on.

I also recommend against depending on new windows.

Absolutely.

Richard.
 
J

Jim Ley

except that Pocket IE apparently
lacks a global 'window' property so even that test will error ("window
is null or not an object!, though Pocket IE does not report errors by
default).

That's not quite right with PIE, window object exists, but going
anywhere near window.open results in an untrappable error.

The only "browser" I know of that doesn't follow the window/global
object convention is Corel SVG Viewer 1.

Jim.
 
R

Richard Cornford

Jim Ley said:
That's not quite right with PIE, window object exists, but going
anywhere near window.open results in an untrappable error.

OK. I haven't had a chance to have a real poke around Pocket IE yet. I
would love the chance to run my DOM scanning script over it but I doubt
that it has the onboard memory to support such a big script (Palm OS
browsers always run out of memory with it :( ).
The only "browser" I know of that doesn't follow the
window/global object convention is Corel SVG Viewer 1.

I knew someone had mentioned an environment without a reference to the
global object. I must have mentally put that together with your warnings
about window.open on Pocket IE. Thanks for sorting it out.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top