I am writing an userscript (for greasemonkey/firefox) to be used in a webpage.
It contains a series of tag with a onmouseover attribute that do the following:

<area class="linkPoly" shape="poly" coords="450,175,412.5,200,450,225,487.5,200" href="home.php?msg=hello" onmouseover="showinfo('hello<br> world');">

the showinfo() function simply puts the html text passed by argument in a accessible by ID.

What I am trying to do is scan the webpage for all the possible arguments of this function and perform some operations.

The point is that I would like to access the String passed to showinfo() as an HTML object in order to avoid parsing the entire string.

I have tried doing the following:

var content="the html I have taken from showinfo"
var el = $( '<div></div>' );
el.html(content);
GM_log(el.innerHTML);

but I get an Undefined error in the console.

Can anyone see what I am doing wrong?

有帮助吗?

解决方案

The el is jQuery object and you are trying to use innerHTML on it. Convert jQuery object to DOM object to use innerHTML property as it is not available with jQuery object.

GM_log(el[0].innerHTML);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top