Topic: new window Pages that link to <a href="https://ozoneasylum.com/backlink?for=23446" title="Pages that link to Topic: new window" rel="nofollow" >Topic: new window\

 
Author Thread
josh
Bipolar (III) Inmate

From:
Insane since: Jul 2003

IP logged posted posted 09-27-2004 06:03 Edit Quote

this is going to sound really, really dumb. i've forgotten the command to open a link in a new window. in fact, i don't even know if i ever knew.

many thanks in advance

(Edited by josh on 09-27-2004 06:04)

templar654
Bipolar (III) Inmate

From: Beyond that line...
Insane since: Apr 2004

IP logged posted posted 09-27-2004 14:18 Edit Quote

Believe me... if you've read some of my previous posts I don't think you'd like me to say anything!!

Seriously I'm humiliating myself just by typing this!

<a href="#" onClick="window.open('shame_on_you.htm', 'damn_man', 'width=xxx, height=xxx, resizable=yes/no, scrollbars=yes/no')">

Change the following:

  • shame_on_you.htm to the link of the page to open
  • damn_man to any name
  • xxx to width height without px
  • yes/no to you decide



Here lie the remains of Templar654's sig... *sniff*
Cell #23041 | View File

(Edited by templar654 on 09-27-2004 14:20)

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

IP logged posted posted 09-27-2004 18:08 Edit Quote

or simply add target="_blank" to your <a> tag and avoid the akward javascript command with it's inherent problems...

Seeing as this is the HTML forum, an HTML solution seems more fitting than a belittling and snide javascript solution.

josh
Bipolar (III) Inmate

From:
Insane since: Jul 2003

IP logged posted posted 09-28-2004 12:09 Edit Quote

good point there DL-44. it's been a while and i have to dive back into all this. all fixed, cheers!

(Edited by josh on 09-28-2004 12:10)

Tekapo
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

IP logged posted posted 09-29-2004 08:23 Edit Quote

Hi, Josh. Good work, mate.
How are you doing?

josh
Bipolar (III) Inmate

From:
Insane since: Jul 2003

IP logged posted posted 10-16-2004 01:56 Edit Quote

Hello there "Tekapo", all's well, how's your complicated PHP going?

Tekapo
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

IP logged posted posted 10-18-2004 02:00 Edit Quote

Hi, Josh. How are ya? I have been missing you and your family very much. Please say hi to your dad especially, mate. I have been doing Visual Basic for a while. I have not had a chance to play around with PHP, mate. Keep good work, mate. Cheers.

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

IP logged posted posted 10-20-2004 03:05 Edit Quote

It might be worth mentioning that in XHTML (strict I think), the target attribute has been deprecated and so a window.open() call should be used for opening in a new window. (Almost seems backwards in some ways to me, but I assume I'm missing something.)

(Edited by Scott on 10-20-2004 03:06)

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 10-20-2004 04:36 Edit Quote

Yeah, in order to get my home page to validate as XHTML strict, I ended up with this syntax:

<a href="http://www.someplace.com/" onclick="window.open(this.href,'_blank');return false;">SomePlace</a>

But I was very sorry to lose the target="_blank" solution from good old HTML.

(Edited by Bugimus on 10-20-2004 04:38)

reitsma
Maniac (V) Mad Scientist

From: the smaller bedroom
Insane since: Oct 2000

IP logged posted posted 10-20-2004 08:15 Edit Quote

Hey Bugs!

Well.... here's something that i found, for a different (nicer, maybe?) way of doing it.

Specify your old target=_blanks as follows:

code:
<a href="http://www.google.com.au/" rel="external">new window</a>



THEN.... put this little script goody in your code as well!

code:
<script type="text/javascript">
function externalLinks(){

if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++){
var anchor = anchors[i];
if (anchor.getAttribute("href") && anchor.getAttribute("rel")
=="external") {
anchor.target = "_blank";
}
}
}
window.onload = externalLinks;

</script>



it's compliant, and it works. whether it's the best solution for you.... well, that's for you to decide, isn't it!


reitsma

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 10-20-2004 17:42 Edit Quote

Hey reitsma!

That is nifty and saves having to add the ugly text to each anchor tag. What's interesting though is how it still assigns the target attribute to the anchor. This will certainly validate because script is not checked but I wonder if assigning the target to the anchor by other means is ok. It's a very interesting question and one I do not know the answer to.

What would happen for instance if we had a browser that did not honor the target attribute at all if the doc type was XHTML strict? Would this method then be blocked? What do you think?

: . . DHTML Slice Puzzle : . . .

reitsma
Maniac (V) Mad Scientist

From: the smaller bedroom
Insane since: Oct 2000

IP logged posted posted 10-25-2004 08:21 Edit Quote

excellent point bugs...

i suppose if the browser decides to honor the doc type in its DOM, then this method may not be the best.

i've done some basic testing, and it seems that i couldn't modify the 'onclick' attribute of the link, but i can modify the href. So you could rewrite all the hrefs to "javascript:window.open(url)" perhaps...

but... that's making this hack look a little more hackish... so i dunno.

reitsma



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu