homepage Welcome to WebmasterWorld Guest from 54.82.122.194
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
inquiry about javascript code
mike2010




msg:4453964
 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++) {
resultArray.push(tags[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

MB

 

mike2010




msg:4453981
 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>

Fotiman




msg:4454137
 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:
[quirksmode.org...]

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved