Solved

getOwnPropertyNames in IE

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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)
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now