Solved

getOwnPropertyNames in IE

Posted on 2014-01-30
2
529 Views
Last Modified: 2014-01-30
Hi,

I am using these functions to check the querystring for parameters and their values and then loop through and pass them to another function.
However, IE doesn't like getOwnPropertyNames. Is there an alternative I can use?

setTrackParams = function(){
	var params = qbtbUS.getUrlVars();
	var forms = $("form");

	if(typeof Object.getOwnPropertyNames(params).length !== 0){
		$.each( forms, function( key, value ) {
			qbtbUS.createSubmitFields(value, params);
		});
	}
}

getUrlVars = function() {
	var search = window.location.search;
    var params = {};
	if (search.charAt( 0 ) == '?' ) {
		search = search.substring(1);
        var hashes = search.split('&');
        var i,len = hashes.length;
        for(i = 0; i < len; i+=1) {
          hash = hashes[i].split('=');
          params[hash[0]] = hash[1];
	 }
  }
  return params;
}

Open in new window

0
Comment
Question by:Al4ddin2
  • 2
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39820730
Try this :
setTrackParams = function(){
	var params = qbtbUS.getUrlVars();
	var forms = $("form");

	var l = 0;
	for(var i in params) l++;
	if(l) {
		$.each( forms, function( key, value ) {
			qbtbUS.createSubmitFields(value, params);
		});
	}
}

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 39820791
Another one :
setTrackParams = function(){
	var params = qbtbUS.getUrlVars();
	var forms = $("form");

	for(var i in params) break;
	if(i) {
		$.each( forms, function( key, value ) {
			qbtbUS.createSubmitFields(value, params);
		});
	}
}

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question