Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Javascript include and opening new windows ?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
wii Posted - 28 July 2008 : 05:33:52
Hi,

I have a simple javascript from an external provider, something like this:

<script language="javascript" src="http://external.com/oneinclude.js"></script>

It works just fine, but I would like all the links that this script includes to open in a new window, is there anyway I can do this editing just the include? As I donīt have access to the file itself.

Thanks a lot<
15   L A T E S T    R E P L I E S    (Newest First)
wii Posted - 07 October 2008 : 03:38:30
Yeah, done that - doesnīt work.

Iīm gonna give up on this one...<
Carefree Posted - 06 October 2008 : 11:55:13
Anywhere within the < body> < /body> should work. Some claim that you get the best performance by putting scripts immediately before the close of the body. I haven't noticed any appreciable improvement one way or the other, so I cannot attest to the legitimacy of that.

<
wii Posted - 06 October 2008 : 08:46:14
Yeah, Iīve tried that - I think my problem is that I donīt know where and how to insert the code for the 2nd part, the first part is obvious to include the javascript code in my HTML, but how do I include the 2nd code ?

I have tried to include it like this in the HTML page, but that doesnīt work:

<script language="javascript" type="text/javascript">

document.getElementById('externalProvider').onclick = function (evt) {
evt = evt || window.event;
targ = evt.target || evt.srcElement;
// this = the div element
// targ = the clicked on element
if (targ.nodeName !== 'A') {
return;
}
window.open(targ.href);
}
</script><
Carefree Posted - 06 October 2008 : 07:31:51
quote:
Originally posted by wii

Yes, they all link to the same site, I received an answer from another forum, which didnīt work for me:

http://www.sitepoint.com/forums/showthread.php?t=561642

Any help is appreciated, thanks.



That php site is plagued by the same scrollcode/code issue we had here: it incorrectly strings all code in one line if you copy/paste.
These will copy/paste correctly.
The 1st part of the code from PMW57 should read as below:
<div id="externalProvider">
<script language="javascript"
    src="http://external.com/oneinclude.js"></script>
</div>

The 2nd part of the code from PMW57 should read as below:
document.getElementById('externalProvider').onclick = function (evt) {
    evt = evt || window.event;
    targ = evt.target || evt.srcElement;
    // this = the div element
    // targ = the clicked on element
    if (targ.nodeName !== 'A') {
        return;
    }
    window.open(targ.href);
}


See if that fixes it.<
wii Posted - 06 October 2008 : 03:08:53
If I could just get the **** code to work posted by someone at Sitepoint, I would be happy.<
AnonJr Posted - 01 October 2008 : 13:48:37
I guess Shaggy's "out to lunch"? (couldn't help it)

If his work schedule has been anything like mine has been lately I can certainly understand.<
HuwR Posted - 01 October 2008 : 12:38:41
obviously an extended one <
wii Posted - 01 October 2008 : 07:22:18
How was lunch ? <
Shaggy Posted - 23 September 2008 : 04:08:35
It should be easy; maybe it's the brain fail I've been suffering from the past few months that's throwing me off the scent - gonna give it 1 more try over lunch this afternoon.

<
wii Posted - 23 September 2008 : 03:45:00
I know itīs not easy, but there must be a way to do this.<
Shaggy Posted - 12 September 2008 : 04:10:32
No joy as yet, man.

<
Shaggy Posted - 11 September 2008 : 04:18:17
Oop; sorry, buddy, forgot all about this somehow I'll have another look this afternoon.

<
wii Posted - 11 September 2008 : 03:07:46
Anyone ?<
wii Posted - 26 August 2008 : 05:55:40
Shaggy, any news about this ?

Thanks<
wii Posted - 22 August 2008 : 06:58:03
Mail sent !<

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000 Version 3.4.07