Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

inquiry about javascript code

11:53 pm on May 15, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
votes: 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

12:55 am on May 16, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:July 10, 2005
votes: 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>
1:56 pm on May 16, 2012 (gmt 0)

Senior Member from US 

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

joined:Oct 17, 2005
votes: 14

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.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members