Tag-Archive for » javascript «

2010-11-30 18:30:56 | Author:

normally, when you create a new iframe and set its src to about:blank, you can access its contents, like this:

bla.innerHTML = '<iframe src="about:blank" id="foo" ></iframe>';

// and, once its loaded:

document.getElementById('foo').contentWindow.document.write('things...');

Internet Explorer, at first glance pretty randomly, explodes in your face with an “Access denied” message when you try to access the document.
I suspected lots of different things, and needed days to finally figure it out:

If the parent window’s document.domain property has been explicitly set at some point, an empty frame is treated as belonging to different domain.

And because we cannot cross domain boundaries, yadda yadda yadda, access to their content is denied.

Workaround: set the iframe’s source not to “about:blank”, but to “blank.html”, for example. It does not matter if that page exists or not: to Internet Explorer, the frame willl be from the same domain, and all is well. That’s actually the same thing doubleclick/ Google Ads does.

Category: DOM  | Tags: , , ,  | Leave a Comment
2009-12-24 21:28:21 | Author:

Dadumdidum… ECMAScript5 (“JavaScript”) gefällt mir. Und weil’s so schön ist, implementier ich schon mal die neuen Arraymethoden… bspw.:

if (typeof Array.prototype.indexOf === 'undefined') {

	/**
	* 15.4.4.14
	* NOTE the second parameter fromIndex is not explicitly stated so that the
	*      method's length property becomes 1
	*
	* @param searchElement array element to be searched for
	* @param fromIndex (optional, integer)
	*/
	Array.prototype.indexOf = function (f) {
		var l = this.length,
			i = arguments[1] || 0;

		i += (i < 0) ? l : 0;

		for (i = Math.max(i, 0); i < l; i += 1) {
			if (this[i] === f) {
				return i;
			}
		}
		return -1;
	};
}

…außerdem gefällt mir dieses Syntax-Highlighting hier :D
to be extended…

2009-10-31 11:12:08 | Author:

When trying to add a javascript plasmoid to the KDE Destop (kubuntu 9.10 aka karmic), it showed only this message:

Could not create a javascript ScriptEngine

Very helpful indeed.
Turns out I had to install the package plasma-scriptengine-javascript .

Category: blah  | Tags: , , , ,  | Leave a Comment
2009-10-24 20:33:57 | Author:

When having a romantic streak, normal heart shapes are not enough for me. They have to be special. That’s why I wrote an ASCII art generator.
Be warned: It works in Firefox 3.5, and I suspect nowhere else. I do not care enough, but if you want to improve upon things, I put the code on github.
Also, it’s really slow, but that’s the prize to pay for doing graphics in Javascript. ;)

       ''
          ,wNWWWH|
       'WWWWWWWWWWWWWc        ~"tc!':-^>oRt,
      WWWW#        /WWW0    ,Yt)         ^1WW`
     WWW1\            WWWV !)^-M`": ^"  \   !Wo~
    WWW   :      Wj   WWWWWW}':    tW        MW,
    WWC  J      ^WWWWWW= :WWW0~ ,<@WWNRWBWt``WAc
   'WW  MT,-     'zHo^  ^   /JWWWs>/      'NWr >
   3WWD     ,:"~- :          )WW  ,         W-
    aWWzWf !A[             |  3  `^        !  W
     zWWWWD#}  yW   W        NM          WW  Wr
      @WWWWWWWWr         -WWWWWW'        WRkW^
         xWWWW9c'> ,,   8W0~'JMWWWx     WWWo
           >@W2tHBWWX  :WN      WW,   WWW^
             ~0 +   cW   vW     EW'hWWw
               -wk4x^Wx        vWWWt
              v   `+6A[!:'   %WWD
                       "^' 4WWW
                        :^ WW{W
                         vW}
                          W         

(I took the liberty of using an image by Aleksejs Kostins here).

Category: blah  | Tags: , , , ,  | 3 Comments