Links opening in new windows
Links opening in new windows
Any idea how I can make all external links open in new windows other than editing each link with a target:"_blank" ?
Cheers
Ian
Cheers
Ian
75% of people make up three quarters of the World's population!
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Links opening in new windows
Hi!
I think there are javascripts that do this.
BUT: How to open links and windows should be a browser issue. The user should decide how he wants that, and tell his browser to adapt to this. I'm really a big opponent of target_blank.
Best regards,
Garvin
I think there are javascripts that do this.
BUT: How to open links and windows should be a browser issue. The user should decide how he wants that, and tell his browser to adapt to this. I'm really a big opponent of target_blank.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Links opening in new windows
Ooh! I'm not! I hate it when someone navigates away from one of my sites just because they have clicked a link. I want them to stay! And buy or commission stuffgarvinhicking wrote:I'm really a big opponent of target_blank.
75% of people make up three quarters of the World's population!
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Links opening in new windows
Hi!
If they WANT to stay, they would open your links in a new window via Shift/Middle-Mouse click.
Don't think about what your visitor can do for you, think about what YOU can do FOR your Visitor! Then they will stay on your site on their own.
It's all about giving power to people. I'm a strong fighter for this concept, which is why I develop Serendipity.
Best regards,
Garvin
If they WANT to stay, they would open your links in a new window via Shift/Middle-Mouse click.
Don't think about what your visitor can do for you, think about what YOU can do FOR your Visitor! Then they will stay on your site on their own.
It's all about giving power to people. I'm a strong fighter for this concept, which is why I develop Serendipity.
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Links opening in new windows
You give surfers too much credit. The average surfer has no idea they can do that.garvinhicking wrote:If they WANT to stay, they would open your links in a new window via Shift/Middle-Mouse click.
I tend to agree with nation-x. We get so close to computers sometimes that we forget that 99.9% of computer users only turn them on once a week to look at email.
I don't quite understand. Does this go in a head nugget do you mean? Surely an ordinary html nugget couldn't affect the whole site.add and HTML nugget
put <BASE target="_blank">
75% of people make up three quarters of the World's population!
Ive used this before http://www.dynamicdrive.com/dynamicinde ... indow2.htm
Nation-x - I tried yours but then every link opens a new page - neat, but a bit excessive.
dk70 - I'm afraid I can't get that Javascript to work anywhere without breaking the site. It needs to be in the <body> so i've tried content, entries and index.tpl's
Where did you use it?
dk70 - I'm afraid I can't get that Javascript to work anywhere without breaking the site. It needs to be in the <body> so i've tried content, entries and index.tpl's
Where did you use it?
75% of people make up three quarters of the World's population!
Javascript should work in the index.tpl. However, since the index.tpl is parsed by Smarty, and both Smarty and Javascript assign special meaning to the curly braces "{}", there's going to be a conflict.
Smarty is going to win, since it goes first -- on the server, whereas Javascript has to wait until the client's browser is ready to execute it.
To slip the braces past Smarty and on to Javascript, you need to convince Smarty to either ignore the braces, or generate them.
Ignoring the braces is the simpler solution. Smarty passes on anything between {literal} tags, thusly:
Simple enough: just enclose all your Javascript in {literal} tags.
Generating the braces isn't difficult, just annoying. Smarty will turn any instance of {ldelim} into a left-curly-brace, and any instance of {rdelim} into a right-curly-brace. Thusly:
Also relatively simple: just replace all occurrences of "{" with {ldelim} and all occurrences of "}" with {rdelim} in your Javascript only.
Finally, you can bypass Smarty altogether and put Javascript directly in your header. Use the "Head Nugget" to put arbitrary HTML (including Javascript or meta tags) in the head of your page output.
When you visit your page, if your Javascript doesn't work as expected, first check the page source. If the script looks like you wanted, there's likely a problem with the script. If it's missing all its braces, you need one of the solutions above.
Smarty is going to win, since it goes first -- on the server, whereas Javascript has to wait until the client's browser is ready to execute it.
To slip the braces past Smarty and on to Javascript, you need to convince Smarty to either ignore the braces, or generate them.
Ignoring the braces is the simpler solution. Smarty passes on anything between {literal} tags, thusly:
Code: Select all
{literal}
some_javascript
{
with(braces);
}
{/literal}
Generating the braces isn't difficult, just annoying. Smarty will turn any instance of {ldelim} into a left-curly-brace, and any instance of {rdelim} into a right-curly-brace. Thusly:
Code: Select all
some_javascript
{ldelim}
with(braces);
{rdelim}
Finally, you can bypass Smarty altogether and put Javascript directly in your header. Use the "Head Nugget" to put arbitrary HTML (including Javascript or meta tags) in the head of your page output.
When you visit your page, if your Javascript doesn't work as expected, first check the page source. If the script looks like you wanted, there's likely a problem with the script. If it's missing all its braces, you need one of the solutions above.
Brilliant! Worked first time.
Thank you so much Judebert
---added---
This has really got to be the most useful mod I have ever made to any of my Serendipity websites - and so simple! I've already added it to all my client's sites. It makes life so much easier.
Thank you so much Judebert
---added---
This has really got to be the most useful mod I have ever made to any of my Serendipity websites - and so simple! I've already added it to all my client's sites. It makes life so much easier.
Last edited by Ianardo on Wed Jul 26, 2006 3:49 pm, edited 1 time in total.
75% of people make up three quarters of the World's population!
Re: Links opening in new windows
well... you did say "all".Ianardo wrote:Any idea how I can make all external links open in new windows other than editing each link with a target:"_blank" ?
Cheers
Ian
Re: Links opening in new windows
Naaa, "all external"nation-x wrote:well... you did say "all".Ianardo wrote:Any idea how I can make all external links open in new windows other than editing each link with a target:"_blank" ?
Cheers
Ian
75% of people make up three quarters of the World's population!
I used same head nugget as judebert mentioned.
To add something useful may be try Smart-Cursor if you use Firefox https://addons.mozilla.org/firefox/2771/ Can get same result without extension, just somelines in usercontent.css, but this is easier. Works just fine in Firefox 2.0 Beta - use this if you dont want to edit install file http://users.blueprintit.co.uk/~dave/we ... index.html
To add something useful may be try Smart-Cursor if you use Firefox https://addons.mozilla.org/firefox/2771/ Can get same result without extension, just somelines in usercontent.css, but this is easier. Works just fine in Firefox 2.0 Beta - use this if you dont want to edit install file http://users.blueprintit.co.uk/~dave/we ... index.html