html request

LordOfLA

Godlike!
Joined
2 Feb 2004
Messages
7,026
Code:
<a href="http://www.osnn.net" target="_blank">OSNN</a>
Naturally there will be code needed to check if an option is set as to whether it should put the target attribute there.

In php you could do something like

Code:
<?php
    if ($new_window == true)
    {
        echo "<a href=\"http://www.osnn.net\" target=\"_blank\">OSNN</a>";
     }
     else
     {
        echo "<a href=\"http://www.osnn.net\">OSNN</a>";
     }
?>
May need to replace \" with ' been a few months since I last did PHP coding.

May also just set a variable called $target_attribute to contain target="_blank" if $new_window is set and just echo it in the tag - if its not set nothing shows, if it is you get the target attribute set.
 

Perris Calderon

dealer
Staff member
Political Access
Joined
24 Jan 2002
Messages
12,374
Code:
<a href="http://www.osnn.net" target="_blank">OSNN</a>
Naturally there will be code needed to check if an option is set as to whether it should put the target attribute there.

In php you could do something like

Code:
<?php
    if ($new_window == true)
    {
        echo "<a href=\"http://www.osnn.net\" target=\"_blank\">OSNN</a>";
     }
     else
     {
        echo "<a href=\"http://www.osnn.net\">OSNN</a>";
     }
?>
May need to replace \" with ' been a few months since I last did PHP coding.

May also just set a variable called $target_attribute to contain target="_blank" if $new_window is set and just echo it in the tag - if its not set nothing shows, if it is you get the target attribute set.
thanx, will pass it on, I doubt they know enough to make it work but they'll have something to research
 

Electronic Punk

willalwaysbewithyou
Staff member
Political Access
Joined
2 Dec 2001
Messages
18,680
I used to use these on the frontpage, but speedy said something I am always reminded of when looking over these things - if folks wanted to open pages in a new window they would do it themselves :)
 

jukkish

OSNN Newbie
Joined
3 Dec 2008
Messages
2
I used to use these on the frontpage, but speedy said something I am always reminded of when looking over these things - if folks wanted to open pages in a new window they would do it themselves :)

I think good rule is to open external links to new windows and internal links to same window.


I'm not sure if check box is done with php, I would suspect javascript and possibly AJAX, because it doesn't seem to reload page after checking or unchecking the box.
 

Geffy

OSNN Veteran Addict
Joined
18 Mar 2002
Messages
7,805
I think in a world of tabbed browsers and being able to middle click "open link in new tab" no link should ever open in a new window. Some popups have their place but thats rare.

Also if your using the target attribute remember to set your HTML Doctype to HTML4 and not XHTML as target isn't valid in XHTML. I can't remember whats happened to it in HTML5.
 

Perris Calderon

dealer
Staff member
Political Access
Joined
24 Jan 2002
Messages
12,374
I think in a world of tabbed browsers and being able to middle click "open link in new tab" no link should ever open in a new window. Some popups have their place but thats rare

we all have our preferances geffy, that's why this feature is an opt in rather then default

I personally would much rather a new window then a new tab when I'm on a page that I don't want to navigate away from

while I do use tab browsing at times, to me it is redundant, if you open a new window there is a tab for that window in your task bar and I just don't get the whole tabbed browser fetish

amyway, the feature on this site is opt in and that satisfies everyone, those like yourself who believe you should not "break the back button" and those like me who think you should not be mavigating from a page you haven't finnished

by the way, what is the code to add to links if you want a tab to open in the backround instead of the forground
 
Last edited:

LordOfLA

Godlike!
Joined
2 Feb 2004
Messages
7,026
well for people like me tabbed browsing means my task bar buttons dont get shrunk down to application icons with all the windows I would have open.

Browser configuration will change link behaviour to new windows or tabs.
 

Perris Calderon

dealer
Staff member
Political Access
Joined
24 Jan 2002
Messages
12,374
well for people like me tabbed browsing means my task bar buttons dont get shrunk down to application icons with all the windows I would have open.
true enough but then you take up real estate below the title bar and I canot stand that

6 or half a dozen, it's preference and that's all, that's why it's such a good idea to let the user decide

Browser configuration will change link behavior to new windows or tabs
I like the way my browser opens links on most sites now and don't want a different configuration, I don't want every link opening in a new window, links off site I like to open in a new window, windows on site I want to open in the same window

just the way this board functions I might add

that's the beauty of the feature, the user decides how they want the page to address links not the person coding the site...brilliant concept
 
Last edited:

osnnraptor

OSNN Newbie
Joined
10 Dec 2008
Messages
6
this particular site uses javascript (php is not a good option since after you check the checkbox you need to reload the page)
Code:
<script type="text/javascript">
<!--
// thanks to randomwalks.com for this code

function targetLinks(boNew)
{

if (boNew) where = "_blank";
else where = "_self";
for (var i=0; i <=(document.links.length-1); i++)
{

if (document.links[i].href.indexOf("javascript") == -1 ){
document.links[i].target = where;
}
}


} 


//-->
</script>
 
Last edited by a moderator:

Members online

No members online now.

Latest profile posts

Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,590
Latest member
AntonioPR