The original code for the default value was initially like this:
<script type="text/javascript" language="JavaScript"><!--
document.write('<input ');
document.write(' type="text" ');
document.write(' name="website" ');
document.write(' size="50" ');
document.write(' value="' + document.URL + '">');
//--></script>
<noscript>
<input name="website" size="50" type="text">
</noscript>
Any help will do :-)
Hi,
I have this very simple yet handy extension which opens an html popup
with a form in it.
The first field contained by default, the current url as shown in the
browser.
The problem was when the extension window closed, and the user moved
to another chrome tab and click the extension button again, the filed
had the old value of the previous url, and not the current tab url.
(It's a simple html page with some JavaScripts.)
The original code for the default value was initially like this:
<script type="text/javascript" language="JavaScript"><!--
document.write('<input ');
document.write(' type="text" ');
document.write(' name="website" ');
document.write(' size="50" ');
document.write(' value="' + document.URL + '">');
//--></script>
<noscript>
<input name="website" size="50" type="text">
</noscript>
Any help will do :-)
--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
<script>
chrome.tabs.getSelected(null, function(tab) {
var url1 = tab.url;
});
document.write("<input type='text' name='website' size='50'
value="+url1+"'>");
</script>
but it didn't work...
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.
> > For more options, visit this group at
> >http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.
>
> --
> Ask your next question on Stack
> Overflow<http://stackoverflow.com/questions/ask>,
> using the google-chrome-extension<http://stackoverflow.com/questions/tagged/google-chrome-extension>tag.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
<script>
chrome.tabs.getSelected(null, function(tab) {
var url1 = tab.url; // <--- This gets executed in a separate thread
});
/* url1 likely doesn't exist yet, because the above
thread is still being initialized (a "race condition") */
document.write("<input type='text' name='website' size='50' value="+url1
+"'>");
</script>
To solve that, you can create a function which will be called from
inside the callback function, like so:
function doSomething(tabUrl) {document.write("<p>"+tabUrl+"</p>"); }
chrome.tabs.getSelected(null, function(tab) {
doSomething(tab.url);
});
Or write everything within the callback function.