using Array methods over frame borders?
The other day i tried to join a javascript Array to pass it over to another page within my application.
I stumbled upon the error message in IE7
Unexpected call to method or property access.
Ok, it must have got something to do with a method that is used on an array:
link += "&elements=" + parent.frames[1].arrElements.join("|");
After consulting Google i found several pages, and this is the most targeting link: myArray instanceof Array fails after passing to a different page.
Douglas Crockford states:
When you say ‘Array’, you are talking about ‘window.Array’. ‘window’ is the
browser’s context object, and you get one per page (or frame). All of the arrays
created within a context will have their constructor property set to
‘window.Array’.
So i assume this to be the reason why my call .join() fails.
So what would be a workaround?
I had to create a local array and copy all the elements from the original array into my local array and join this one to the link:
var joinHelper = "";
for (var i = 0, j = arrElements.length; i < j; i++) {
joinHelper += arrElements[i];
if (i < j) {
joinHelper += "|";
}
}
link += "&elements=" + joinHelper; // instead of parent.frames[1].arrElements.join("|");
… time to call it a day …
l10n 1.0
I finally finished to upload a new version of my jQuery Plugin l10n. This is the first official release with version 1.0 as it now supports all html elements that can be localized. E.g. Images can now be localized and also Drop Down Lists and of course all the other elements that can contain texts.
slider with not linear values
Yesterday i was searching for a solution to have the jQuery slider having values that are not linear from min to max but with different “linearities”. I found a solution that fitted my needs here:
http://stackoverflow.com/questions/967372/jquery-slider-how-to-make-step-size-change/967565#967565
isNullOrEmpty
Coding a lot in JavaScript i often have to check if an object is
undefined, null or at least an empty string.
So it would be great to have a method like in C#
string.isNullOrEmpty()
This is my solution for JavaScript:
window.isNullOrEmpty = function(obj) {
return (obj === '' || obj === null || obj === undefined)
}
And the best of it: it does not only work on strings like in C#, it works for every object.
Attatching the method to the window object makes it purely available from everywhere.
<title /> vs <title></title>
The other day i was hunting a very strange bug that occured in IE8. I’ ve got a frameset where i have a
otherframe.location.href = somelink;
This leads to a blank screen in the browser window where i am even not able to view the source code. Every time i clicked the right mouse button i got an
“Access denied”
on that very line.
I googled a lot but did not find the solution. So i used as many alert(); boxes as possible until i finally found out that the title-tag seemed to be not well formed. I don’t have an idea why
<title />
is not well formed, but IE taught me that. So i will use
<title></title>
in the future…
uploaded l10n – my first jQuery plugin
finally i managed to upload my first jQuery plugin l10n It’s a nice bit of code handling all the localization stuff that you need for your web application as we use JSON objects for storing all the strings. What is more, the JSON objects can be generated by converting “.NET *.resx” resource files with XML2JSON. We are about to use it in our company for a new product.
This one should not be the last, as developing plugins for jQuery is that simple and very effective.
where do you want to go today
having this bit of a slogan in mind i decided to join the blogging people. Why? I was longing for some space where i can put up my plugin for jQuery and decided to do this here. This will follow later that evening. So long…