i have a chrome extension which dynamically create an iframe with a button for each chrome tab.
For this action From background.js i send message to content.js
chrome.tabs.sendMessage(tabs[0].id, {action: "load_ifram~"+id}, function(response) {});content.js:chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) { split_message = msg.action.split("~"); if (split_message[0] == 'load_ifram') { var id = split_message[1]; var height = '35'; var iframe = document.createElement('iframe'); iframe.src = chrome.extension.getURL('toolbar1.html'); document.documentElement.appendChild(iframe); } });toolbar1.html<!DOCTYPE html> <html> <head> <script type="text/javascript" src="test.js"></script> </head> <body> <input type="text" name="value" id="value" value=""/> <button id="p_button" style="float:right;line-height:15px;margin-top:-1px;font-family:century gothic;">Click ME</button> </body>test.js:document.addEventListener('DOMContentLoaded', function () { var p_status = document.querySelector('#p_button'); if(p_status ){ p_status.addEventListener('click', p_open); } });In content.js i am getting id from background.js. this id should be the value for my button(Click ME+ id).
function p_open(e) {
window.open("http://wwww.mysite.com?send_id=id");
}
Also I want to use to this id in my button click function(p_open()).
Is it possible to do something like this?
How can i do this? please help!! Thanks in advance
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/2cd238fe-57ac-4c57-b4ce-cd416d802dad%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.