| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
Dr. Lucien Sanchez
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. |
|
|
|
|
|
#2 (permalink) |
|
volkswagen yellow & gold
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' |
|
|
|
#3 (permalink) | |
|
Dr. Lucien Sanchez
Join Date: Mar 2003
Location: UK
Posts: 5,632
|
Quote:
How do I edit the script to say 'open full'? |
|
|
|
|
#4 (permalink) | |
|
This is it - ground zero.
|
Quote:
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. |
|
|
|
|
#5 (permalink) |
|
Dr. Lucien Sanchez
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. |
|
|
|
#7 (permalink) |
|
Registered User
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:
That's the javascript code and this is the link: Code:
This means that even if Javascript is disabled, the link still works (only not in a new window, but this obviously cannot be helped). |
|
|
|
#8 (permalink) |
|
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 |
|
|
|
#10 (permalink) |
|
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.) |
|
|
|
#11 (permalink) | |
|
volkswagen yellow & gold
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
|
Quote:
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. |
|
|
|
|
#12 (permalink) | |
|
volkswagen yellow & gold
Join Date: Apr 2003
Location: london, england.
Posts: 6,214
|
Quote:
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 ( |
|
|
|
|
#14 (permalink) | |
|
Dr. Lucien Sanchez
Join Date: Mar 2003
Location: UK
Posts: 5,632
|
Quote:
|
|
|
|
|
#17 (permalink) | |
|
I Ain't Losing Any Sleep™
Join Date: Apr 2003
Posts: 5,236
|
Quote:
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.
|
|
|
|
|
#18 (permalink) |
|
Dr. Lucien Sanchez
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 |
|
|
|
#20 (permalink) |
|
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:
external via rel attribute: Code:
Last edited by Bill Posters : 29-03-2004 at 13:15. |
|
![]() |