Issue with target bookmarklet

32 views
Skip to first unread message

André Trigo

unread,
Apr 13, 2015, 10:41:47 AM4/13/15
to wei...@googlegroups.com
Hi everyone,

I'm trying to implement weinre with my phonegap project. If I write the <script> tag with the URL to my weinre server it works great, my problem is when I wan´t to inject the target code with a click on an element <a>. 
I put the code to inject on a <a> element like this:
<a href='javascript:(function(e){e.setAttribute("src","http://localhost: 8989 /target/target-script-min.js#test");document.getElementsByTagName("body")[0].appendChild(e);})(document.createElement("script"));void(0);' class="ui-link">DEBUG</a>
But everytime I click on that element it gives me the error :
Uncaught Error: Syntax error, unrecognized expression: #test");document.getElementsByTagName("body")[0].appendChild(e);})(document.createElement("script"));void(0);

I think it may be linked to jquery because the error is on jquery.js in line 4679 

There are any way to resolve that ?

Thanks in advice 

Patrick Mueller

unread,
Apr 13, 2015, 11:35:38 AM4/13/15
to wei...@googlegroups.com
From the console message you got, it appears you simply have a syntax error in that expression.  I would add a global function to your app that loads the weinre target script - it creates the script element, sets the src attribute, etc.  Then your href on the anchor can be <a href="javascript:installWeinre(); void(0);"> to make that part easier, and less prone to syntax issues.
Reply all
Reply to author
Forward
0 new messages