Solved

getOwnPropertyNames in IE

Posted on 2014-01-30
2
523 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

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…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

856 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