Reply LinkBack Thread Tools Search this Thread
Old 26-03-2004, 07:39   #1 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
target=_blank javascript

Because the target attribute is dead (link), I'm using this javascript to launch links classed as external in new windows instead of target="_blank".
In IE, the new window doesn't launch at fullsize. How do I do this?

Thanks

Btw - there's also this: http://www.serve.com/apg/workshop/re...et/better.html if you don't want to use classes.
  Reply With Quote
Old 26-03-2004, 07:56   #2 (permalink)
Brown
volkswagen yellow & gold
 
Brown's Avatar
 
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
aos and flark both use javascript to open windows - they seem to open full size most of the time - help yourself to that if you want, can't remember where i got it from - might have been bill.

as far as i know, the size it opens at is to do with the last size you shut your browser down at, unless you're specfically saying 'open at this size' or 'open full screen'
  Reply With Quote
Old 26-03-2004, 08:17   #3 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
Quote:
Originally Posted by Brown
as far as i know, the size it opens at is to do with the last size you shut your browser down at, unless you're specfically saying 'open at this size' or 'open full screen'
Yeah, that's right.

How do I edit the script to say 'open full'?
  Reply With Quote
Old 26-03-2004, 10:48   #4 (permalink)
roto
This is it - ground zero.
 
roto's Avatar
 
Join Date: Apr 2003
Location: Paper St.
Posts: 4,200
Send a message via AIM to roto Send a message via Yahoo to roto
Quote:
Originally Posted by Stickman
Because the target attribute is dead (link)...
Does this make anyone else say "Uggghhh!!!!"??? Not saying I won't try to comply...it just seems this makes something that was once so easy a bit more of a pain in the ass. Yes yes, I know "standards and all...blah blah blah..."
__________________
fun: HGC v.4 | last.fm: DT | me | oi! f*ck u roto: ...via meebo!

New to interweb design? Your friends at dt can help.
  Reply With Quote
Old 26-03-2004, 11:13   #5 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
It's about assigning the different parts of a website to the correct handlers. xhtml for content, css for styling, scripts for functions etc

It all makes sense if you think about it and it'll make the building and updating of sites easier in future.
  Reply With Quote
Old 26-03-2004, 11:14   #6 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
Oh, and flash for gimmicks...

Only teasing
  Reply With Quote
Old 26-03-2004, 13:47   #7 (permalink)
spl1nter
Registered User
 
spl1nter's Avatar
 
Join Date: Mar 2004
Posts: 33
But what about people who cannot use Javascript or have it turned off?

This is what I use:

Code:
function targetBlank (url) { blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes'); }

That's the javascript code and this is the link:

Code:
<a href='http://site.com' onclick='targetBlank(this.href);return false;'>Site.com</a>

This means that even if Javascript is disabled, the link still works (only not in a new window, but this obviously cannot be helped).
  Reply With Quote
Old 26-03-2004, 17:37   #8 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
Using window.open for generic window creation is a bad idea for at least a couple of reasons (sure to be more, but can't think right now).
One is that it breaks the ability to open links in new tabs (modified-click) for those who prefer to browse that way.
Another is that it won't offer the same visual indications that come with using the target attribute (e.g. Safari states if a link is targeting a new window in the statusbar when you roll over the link).
These little indicators are lost when you use window.open to target a new window.


Using window.open within an inline script is just plain ugly and completely misses the point of seperating markup, style and script.

Fullscreen popups are right up there with leprosy and 'roids in the league of things many people would rather not suffer with.
They really should be avoided unless it's quite critical to the presentation (i.e. kiosk/showcase presentations, etc…).
When it comes to that interweb thingy, no one is going to thank you for using them.

The only good reason to use the window.open method is if the new window genuinely benefits from having its dimensions preset
Few web authors bother to remove the window 'features' - at least, far fewer than used to.

Whichever method you opt for, there's still no good reason to handle it inline.

-

imho™, best option is to use js to reinstate the target attribute for external links.

It also makes it simpler to integrate a target switcher so users can override the _blank target value if they want to.
It's actually possible to handle the switcher, the external link target and any other doodads you wanna include without the need for even the slightest piece of script in the markup.
This, of course, means that the method also degrades cleanly for non-regular and non-js browsers, which is the reason why we're going to such lengths in the first place.


Here's a couple of examples showing the basic principles.
http://demo.newplasticarts.co.uk/externallinks/
http://demo.newplasticarts.co.uk/ext...nks/index2.php
  Reply With Quote
Old 26-03-2004, 20:07   #9 (permalink)
spl1nter
Registered User
 
spl1nter's Avatar
 
Join Date: Mar 2004
Posts: 33
My method degrades as well.
  Reply With Quote
Old 27-03-2004, 03:14   #10 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
I know. I never said that it didn't.
But (again) I point out that using the window.open method has several downsides which the dom target method doesn't have.

You're free to use whichever method you want.
It's about understanding the pros and cons of each method and knowing which would be best for any given situation.

In my view, unless it's critical to customise window features and dimensions for the new window*, then window..open is a short-sighted option.
(* …which you shouldn't be doing if the link is 'external' and leads to someone else's site.)
  Reply With Quote
Old 27-03-2004, 10:44   #11 (permalink)
Brown
volkswagen yellow & gold
 
Brown's Avatar
 
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
Quote:
Originally Posted by spl1nter
But what about people who cannot use Javascript or have it turned off?
it will still have a valid link which they will be able to follow and if they've got javascript turned off, there's probably a very good reason for it, so don't fuck with them and try and force them to do something that they don't want to.

also, i've found issues with going full screen on dual monitors. sometimes the window says its open (you can see it by 'Alt + Tab' but is actually nowhere to be seen on either monitor. right clicking and 'maximise' through the taskbar also don't seem to bring the window into focus. this is (can you belive it?!?) an IE issue only and only when the browser window which launches the new window is not on the default screen.
  Reply With Quote
Old 27-03-2004, 10:52   #12 (permalink)
Brown
volkswagen yellow & gold
 
Brown's Avatar
 
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
Quote:
Originally Posted by Stickman
Yeah, that's right.

How do I edit the script to say 'open full'?
not tested this but its going to be something like: fullscreen=yes within your script brackets.

function PopWin(e) {

if (!e) var e = window.event;
var a = e.target ? e.target : e.srcElement;

var newwin = window.open(a.href, fullscreen=yes);

return !newwin;
}

i might be wrong with the above, can't be arsed to test it ( ) but i think there's a few ways of telling it to go fullscreen.
  Reply With Quote
Old 27-03-2004, 11:06   #13 (permalink)
roto
This is it - ground zero.
 
roto's Avatar
 
Join Date: Apr 2003
Location: Paper St.
Posts: 4,200
Send a message via AIM to roto Send a message via Yahoo to roto
How about go {{insert size here smaller than fullscreen}}?
__________________
fun: HGC v.4 | last.fm: DT | me | oi! f*ck u roto: ...via meebo!

New to interweb design? Your friends at dt can help.
  Reply With Quote
Old 29-03-2004, 04:45   #14 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
Quote:
Originally Posted by spl1nter
This means that even if Javascript is disabled, the link still works (only not in a new window, but this obviously cannot be helped).
Same here but without the clutter in the html. It's only a class in a link tag.
  Reply With Quote
Old 29-03-2004, 04:50   #15 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
Not sure if people knew what I meant - I want the window opened maximised, not fullscreen. Forget it though, I've given up - IE likes to keep the size it was shut down at (just like brown said).
  Reply With Quote
Old 29-03-2004, 05:13   #16 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
Afaik, there is no way to trigger true 'kiosk mode' from within a web page/site.
The 'fullscreen' javascript window feature is as close as it gets.
(99.99…% certain)
  Reply With Quote
Old 29-03-2004, 08:40   #17 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
Quote:
Originally Posted by Stickman
Not sure if people knew what I meant - I want the window opened maximised, not fullscreen. Forget it though, I've given up - IE likes to keep the size it was shut down at (just like brown said).
The screen object has properties availHeight and availWidth which should do what you want.

I'm at work so can't look at it til tonight but will do if you still need it?
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 29-03-2004, 08:50   #18 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,632
Nice one.

Much appreciated - I know nothing about writing javascript.

To recap: external links are isolated by their class using this script:
http://www.serve.com/apg/workshop/replacingTarget/

Cheers beers
  Reply With Quote
Old 29-03-2004, 08:54   #19 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,236
No worries, give me 'til the morning.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 29-03-2004, 11:54   #20 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,899
Sorry. I misunderstood what you were after.

externals via href string:
Code:
window.onload = extLinks; function extLinks() { var links = document.getElementsByTagName('a'); for (var i = links.length; i != 0; i--) { var a = links[i-1]; if (!a.href.indexOf('http:\/\/') && a.href.indexOf('http://demo.newplasticarts.co.uk')) a.onclick = function() { extPop(this.href); return false; }; } } function extPop(url) { newWin = window.open(url,"_blank","top=0,left=0,height="+screen.availHeight+",width="+screen.availWidth+",location,scrollbars,directories,menubar,resizeable,status,toolbar"); }

external via rel attribute:
Code:
window.onload = extLinks; function extLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.onclick = function() { extPop(this.href); return false; }; } } function extPop(url) { newWin = window.open(url,"_blank","top=0,left=0,height="+screen.availHeight+",width="+screen.availWidth+",location,scrollbars,directories,menubar,resizeable,status,toolbar"); }

Last edited by Bill Posters : 29-03-2004 at 13:15.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8