Mark Ros 2009-01-12 15:31
Is there a way to open a new window when I click a link to an external site in stead of replacing my current window? Add target=_blank where?
» Quick.Cms v2.x Mark Ros 2009-01-13 08:28
that is php code which opens that redirection, so You need to replace it by for example edit file actions_client/p.php and replace code with header:
if( !empty( $aData [ 'sUrl' ] ) ){ header ( 'Location: ' . $aData [ 'sUrl' ] ); exit; }
by JavaScript:
if( !empty( $aData [ 'sUrl' ] ) ){ echo 'window.open( ' . $aData [ 'sUrl' ]., "New" , "height=600,width=800,top=0,left=0,resizable=yes,scrollbars=yes,status=0;" ); exit; }
Mark Ros 2009-01-14 14:07
Thanks for the quick response, but it doesn't work. I inserted the following line: echo 'window.open( '.$aData['sUrl'].' , "New", "height=600,width=800,top=0,left=0,resizable=yes,scrollbars=yes,status=0" )'; The output is just the tekst: window.open( http://www.stige.nl , "New", "height=600,width=800,top=0,left=0,resizable=yes,scrollbars=yes,status=0" ) What did I doe wrong?
Mark Ros 2009-01-16 08:36
there is missing " marks outside of url... it should look like that:
if( !empty( $aData [ 'sUrl' ] ) ){ echo 'window.open( "' . $aData [ 'sUrl' ]. ", " New ", " height = 600 , width = 800 , top = 0 , left = 0 , resizable = yes , scrollbars = yes , status = 0 ; " ); exit; }
2009-01-16 12:43
sorry but script this will not work. What's wrong?
cgan Jod 2009-01-17 05:39
This is what I did and it works great... Save the following code as no-follow.js and add file in 'core' directory:
/* JSTarget function by Roger Johansson, www.456bereastreet.com */ var JSTarget = { init : function( att , val , warning ) { if ( document . getElementById && document . createElement && document . appendChild ) { var strAtt = (( typeof att == 'undefined' ) || ( att == null )) ? 'class' : att ; var strVal = (( typeof val == 'undefined' ) || ( val == null )) ? 'non-html' : val ; var strWarning = (( typeof warning == 'undefined' ) || ( warning == null )) ? ' (opens in a new window)' : warning ; var oWarning ; var arrLinks = document . getElementsByTagName ( 'a' ); var oLink ; var oRegExp = new RegExp ( "(^|\\s)" + strVal + "(\\s|$)" ); for (var i = 0 ; i < arrLinks . length ; i ++) { oLink = arrLinks [ i ]; if (( strAtt == 'class' ) && ( oRegExp . test ( oLink . className )) || ( oRegExp . test ( oLink . getAttribute ( strAtt )))) { oWarning = document . createElement ( "em" ); oWarning . appendChild ( document . createTextNode ( strWarning )); oLink . appendChild ( oWarning ); oLink . onclick = JSTarget . openWin ; } } oWarning = null ; } }, openWin : function( e ) { var event = (! e ) ? window . event : e ; if ( event . shiftKey || event . altKey || event . ctrlKey || event . metaKey ) return true ; else { var oWin = window . open ( this . getAttribute ( 'href' ), '_blank' ); if ( oWin ) { if ( oWin . focus ) oWin . focus (); return false ; } oWin = null ; return true ; } }, /* addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */ addEvent : function( obj , type , fn ) { if ( obj . addEventListener ) obj . addEventListener ( type , fn , false ); else if ( obj . attachEvent ) { obj [ "e" + type + fn ] = fn ; obj [ type + fn ] = function() { obj [ "e" + type + fn ]( window . event );} obj . attachEvent ( "on" + type , obj [ type + fn ]); } } }; JSTarget . addEvent ( window , 'load' , function(){ JSTarget . init ( "rel" , "external" , "" );});
Then add this in to head section of templates/container.tpl under list of other <script type=...</script>:
< script type = "text/javascript" src = "$config[dir_core]no-follow.js" > </script>
Then add rel="external" in the anchor tag of links you want to be opened externally, or for example if you want all of menu_4 to open externally use this in menu_4.tpl:
<li class="l$aData[sStyle]"><a href="$aData[sLinkName]" $aData[sSelected] rel="external">$aData[sName]</a>$aData[sSubContent]</li>[/php Hope that works for you, good luck!
Jod 2009-01-17 05:42
Sorry, I missed a ] off the last code section- Then add rel="external" in the anchor tag of links you want to be opened externally, or for example if you want all of menu_4 to open externally use this in menu_4.tpl:
< li class= "l$aData[sStyle]" >< a href = "$aData[sLinkName]" $aData [ sSelected ] rel = "external" > $aData [ sName ]</ a > $aData [ sSubContent ]</ li >
2009-01-19 11:03
But where do you put this rel="external" if you just want one of the links in the menu to be opened external in a new window?
cgan Jod 2009-01-24 19:40
To do that I would either create another menu for that link as per instructions here: http://opensolution.org/Quick.Cms/docs/?id=tips#how_to_add_next_menu OR add the link manually in to menu_*.tpl (where * is number of menu you want to add it to) like this: Find this: <!-- BEGIN FOOT --></ul></div><!-- END FOOT --> Change to this: <!-- BEGIN FOOT --></ul><br/> <a href="your link here" rel="external">link text</a></div> <!-- END FOOT -->
2010-01-19 12:46
I've been trying the method from Wewior without any luck. Does anyone have any ideas how to get it to work?
MarcW 2010-04-05 23:42
Jod, you saved my life. That worked perfect for me. I used it as my customer needed everything in menu3 to open in a new window. Much appreciated. Qwerious, I also tried Wewior's method and couldn't get this to work either. Marc
Marc