homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

inquiry about javascript code

5+ Year Member

Msg#: 4453962 posted 11:53 pm on May 15, 2012 (gmt 0)

this dude is helping me trouble shoot this javascript code in order to help get a 'mouseover' sound effect to work on all 3 major browsers.

All he basically added was this code to the .js file , to get it to work... along with commenting out a couple lines of the original code.

since i'm not a js expert, was just wondering if any of this could be a security issue ? I've only asked for help from the guy a couple times.

function getElementsByTagNames(list,obj) {
if (!obj) var obj = document;
var tagNames = list.split(',');
var resultArray = new Array();
for (var i=0;i<tagNames.length;i++) {
var tags = obj.getElementsByTagName(tagNames[i]);
for (var j=0;j<tags.length;j++) {
var testNode = resultArray[0];
if (!testNode) return [];
if (testNode.sourceIndex) {
resultArray.sort(function (a,b) {
return a.sourceIndex - b.sourceIndex;
else if (testNode.compareDocumentPosition) {
resultArray.sort(function (a,b) {
return 3 - (a.compareDocumentPosition(b) & 6);
return resultArray;

thanks much




5+ Year Member

Msg#: 4453962 posted 12:55 am on May 16, 2012 (gmt 0)

He wanted me to add Jquery to <head> as well...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>


WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4453962 posted 1:56 pm on May 16, 2012 (gmt 0)

That bit of script is 6 years old and you can read about what it does here:

To answer your question, no, it is not a security issue. And that bit of script uses no jQuery, so there must be something elsewhere that's using jQuery.

Lastly, it's best to include all of your scripts at the end of your document just before the closing </body> tag rather than in the <head>.

Hope that helps.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved