javascript - Google Chrome extension that sends a image url into a specific text field -
i trying make google chrome extension allows user click on in image in popup window , have images url sent specific websites text field; see nothing wrong code refuses work.
here manifest.json
{ "manifest_version": 2, "name" : "gifs", "description": "gifs", "version": "1", "permissions": [ "activetab", "http://www.cssflow.com/snippets/login-form/demo", "http://*/*", "https://*/*" ], "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" } }
here popup.html
<script src="jquery.js"></script> <script src="popup.js"></script> <img src="http://www.vidble.com/cayujffa0f.gif" border="0"> <br><br> <img src="http://www.vidble.com/u8l5ghvn5f.gif" border="0">
here popup.js (the id of text field on website want insert urls 'login'.)
$(document).ready(function() { $("img").click(function() { var imageurl = $(this).attr('src'); var script = 'var form = document.getelementbyid("input:#login");' + + 'form.value = (form.value + " ' + imageurl + '");'; chrome.tabs.executescript({code : script}); window.close(); }); });
i following error in console:
unexpected end of input: var form = document.getelementbyid("login");nanhttp://www.vidble.com/cayujffa0f.gif");
any appreciated. in advance.
your problem caused +
in assignment var script
. wonders of javascript:
'a' + 'b' + 'c' -> 'abc' 'a' + + 'b' + 'c' -> 'ananc'
this because second expression interpreted 'a' + (+ 'b') + 'c'
, 'b'
coerced numeric value before being concatenated other strings.
Comments
Post a Comment