Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

use onclick=window.open instead of _target blank


Reply


3 Posts   2912 Views

Avatar
Win-Track

Community Member, 4 Posts

24 October 2010 at 5:26pm

I'm a newbee and just proved it by posting this first in the wrong forum;-) So much to learn!

I am very impressed with SilverStripe so far. One thing that really impresses me is the amount of valid code!

One place puts out invalid code and I think it would be a trivial fix if I knew where to change the code. Perhaps there is a good reason for using a target _blank but i was wondering if it could instead use "onclick=window.open(this.href); return false;" When I am editing a page, click to insert a link, and click the checkbox to open a new window it inserts the html code _target blank. The page is an xtml page and therefore it doesn't validate. If I click the html editor button and fix the html when I click insert the code gets stripped.

Is that a simple fix? Could someone tell me how to do it?

Thanks,
Wade

Avatar
Martijn

Community Member, 271 Posts

25 October 2010 at 12:40am

You can create a textparser to replace all target="_blank" in Content with a class="external" and use jQuery to open those links in a new window..

http://doc.silverstripe.org/recipes:syntax-highlighting#text-parser
http://www.sspaste.com/paste/show/4cac633e6fcd6
http://snipplr.com/view/4626/jquery-snip--open-link-in-new-window/

Avatar
Win-Track

Community Member, 4 Posts

25 October 2010 at 12:26pm

Thanks Martijn

That looks like the info I was looking for. Will take a while till I'm up to speed enough to attempt it though;-) For now I will just add a note to right click to open links in a new window.

Wade