Return web content with the do JavaScript command after Lion

Hello.

The functionality of returning contents with do JavaScript has apparently been broken since Lion.

I found the fix over at Apple Discussusions Forum

The first example is from that page, which demonstrates how to get the current selection.

tell application "Safari"
	activate
	set selectedText to (do JavaScript "var x = ''+document.getSelection();x" in document 1) as string
end tell

The second example is one of my own, which illustrates how to traverse the document tree by an anynomuous self invoking function. it should return the contents of the signatures of a page from macscripter. You should press command opt u, to be able to see the page source to verify that it works. There is a good JavaScript tutorial over at w3schools.com.

tell application "Safari"
	activate
	set signatures to (do JavaScript "var toReturn = ''+ (function () {
	 var eL = document.getElementsByClassName('postsignature') ;
	var  txt = '';
	for (i=0;i<eL.length;i++){
		txt = txt + eL[i].innerHTML ;
	}
	return txt; 
	})();toReturn;" in document 1) as string
end tell
log signatures