Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Javascript include and opening new windows ?
 New Topic  Reply to Topic
 Printer Friendly
Previous Page
Author Previous Topic Topic Next Topic
Page: of 2

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 01 October 2008 :  12:38:41  Show Profile  Visit HuwR's Homepage  Reply with Quote
obviously an extended one <
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 01 October 2008 :  13:48:37  Show Profile  Visit AnonJr's Homepage  Reply with Quote
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.<
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 October 2008 :  03:08:53  Show Profile  Reply with Quote
If I could just get the **** code to work posted by someone at Sitepoint, I would be happy.<
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 06 October 2008 :  07:31:51  Show Profile  Reply with Quote
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.<
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 06 October 2008 :  08:46:14  Show Profile  Reply with Quote
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><

Edited by - wii on 06 October 2008 08:59:40
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 06 October 2008 :  11:55:13  Show Profile  Reply with Quote
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.

<
Go to Top of Page

wii
Free ASP Hosts Moderator

Denmark
2632 Posts

Posted - 07 October 2008 :  03:38:30  Show Profile  Reply with Quote
Yeah, done that - doesn´t work.

I´m gonna give up on this one...<
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Previous Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000 Version 3.4.07