Connecting Tech Pros Worldwide Forums | Help | Site Map

hot spot links to popup

bubipoo
Guest
 
Posts: n/a
#1: Jul 20 '05
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



Knud Gert Ellentoft
Guest
 
Posts: n/a
#2: Jul 20 '05

re: hot spot links to popup


"bubipoo" <god@doodsville.com> skrev :
[color=blue]
> 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?[/color]

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','n o');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/...pup/popup6.htm
(The page is in danish, but look at the source code).
--
Knud
Richard Cornford
Guest
 
Posts: n/a
#3: Jul 20 '05

re: hot spot links to popup


"bubipoo" <god@doodsville.com> wrote in message
news:yUv1b.52300$bo1.47721@news-server.bigpond.net.au...[color=blue]
>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?[/color]

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.


Lasse Reichstein Nielsen
Guest
 
Posts: n/a
#4: Jul 20 '05

re: hot spot links to popup


Knud Gert Ellentoft <knudgert@mail.tele.dk> writes:
[color=blue]
> In <head>:
> <script LANGUAGE="JavaScript">[/color]

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

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

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.
[color=blue]
> win = window.open(mypage, myname, winprops)[/color]

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

Better:
if (win.focus) {win.focus();}
[color=blue]
> }
> // End -->[/color]

Not necessary either.
[color=blue]
> </script>[/color]

I also recommend against depending on new windows.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
HikksNotAtHome
Guest
 
Posts: n/a
#5: Jul 20 '05

re: hot spot links to popup


In article <ue4dkv0g8fnplkempnspa77oo5bggbuojn@dtext.news.tel e.dk>, Knud Gert
Ellentoft <knudgert@mail.tele.dk> writes:
[color=blue]
>In <head>:
><script LANGUAGE="JavaScript">[/color]

language attribute is deprecated in favor of type="text/javascript" which is
mandatory in HTML4.0
[color=blue]
><!-- Begin[/color]

HTML comments are not needed in any modern browser.
[color=blue]
>function NewWindow(mypage, myname, w, h, scroll) {
>var winl = (screen.width - w) / 2;
>var wint = (screen.height - h) / 2;[/color]

What does my screen.width and screen.height have to do with the size of a
preferred window?

screen.width for me is 2048
screen.height for me is 768

run those through your script, and you will attempt to get a window that is :

740 wide
184 high

You might want to reconsider your approach.
[color=blue]
>winprops =
>
>'height='+h+',width='+w+',top='+wint+',left='+win l+',scrollbars='+scroll+[/color]
',resizable=no'[color=blue]
>win = window.open(mypage, myname, winprops)
>if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }[/color]

Browser detection?
And, what about browsers that support focus() but have an appVersion lower than
4?

[color=blue]
>}
>// End -->[/color]

Closing HTML comments following a js comment are not needed.




--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.
Richard Cornford
Guest
 
Posts: n/a
#6: Jul 20 '05

re: hot spot links to popup


"Lasse Reichstein Nielsen" <lrn@hotpop.com> wrote in message
news:u189xmyl.fsf@hotpop.com...
<snip Lots of good advice.>
[color=blue][color=green]
>> win = window.open(mypage, myname, winprops)[/color]
>
>If you don't use the "win" variable outside the function,
>make it a local variable.[/color]

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.

<snip More good advice.>[color=blue]
>I also recommend against depending on new windows.[/color]

Absolutely.

Richard.


Jim Ley
Guest
 
Posts: n/a
#7: Jul 20 '05

re: hot spot links to popup


On Sat, 23 Aug 2003 02:35:51 +0100, "Richard Cornford"
<Richard@litotes.demon.co.uk> wrote:
[color=blue]
> 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).[/color]

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.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Richard Cornford
Guest
 
Posts: n/a
#8: Jul 20 '05

re: hot spot links to popup


"Jim Ley" <jim@jibbering.com> wrote in message
news:3f46c980.20940570@news.cis.dfn.de...[color=blue][color=green]
>> 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).[/color]
>
>That's not quite right with PIE, window object exists, but going
>anywhere near window.open results in an untrappable error.[/color]

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 :( ).
[color=blue]
>The only "browser" I know of that doesn't follow the
>window/global object convention is Corel SVG Viewer 1.[/color]

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.


Closed Thread