I need the toolbar button to execute my custom JavaScript code in Firefox.
Currently I just copy-paste this JS into console, but it is annoying.
What is the best way to create such button?
Use a https://en.wikipedia.org/wiki/Bookmarklet.
Example - create a shortcut to any site on in your browser and replace the URL address with similar code:
javascript:(function(){ alert('Hello!'); })();
Related
I was navigating on this page and clicked "Available for your computer" image.
Then a native browser popup that is like an alert was opened:
Please compare the one above with the following alert() that everybody knows:
How did they create such an alert?
alert seems not to support images, according to this question.
Is this possible to open with JavaScript? I guess yes, but how?
Is this cross-browser? On Firefox, I am redirected to Chrome download page.
NOTE: I DO know that there are a lot of JavaScript libraries to show alerts, but I DO NOT want to use any of them. I want a clear answer to my question.
Chrome has some specialized windows/popups available for it's own use .. things you can't do via regular JavaScript.
Other things you can't do via regular JavaScript are the
Enable Webcam prompt window
Download file window.
If you are trying to do something similar in pure JavaScript, this is a great little replacement:
http://www.codersgrid.com/2013/07/05/alertify-js-replacement-of-your-browser-alert-dialog/
This seems to be a "chrome specific" popup. The application you want to install by clicking on this button is a Google App, which install is handled by Chrome. I think.
Except Bootstrap-like modals, I have never seen such thing in Javascript before.
Check this if you want to implement such popups on your website:
http://getbootstrap.com/javascript/#modals
instead of using alert . you can use any external plugin confirm box.Then you can customize your dialog box
I would like to trigger a Javascript function on an already existing website I don't own by pressing a key.
Example : trigger my_function('my parameter 1'); when I press the 1 key on the keyboard.
I can type manually the command on the Firefox's debugger console, it works. But I can't figure a simple way to trigger the Javascript function from an external program. Can I use Firefox command line ? EventGhost ? AutoHotKey ? Should I write a Firefox extension ?
If your solution implies the use of another web browser you're welcome !
I suggest you to look at this https://api.jquery.com/keydown/. Jquery could be the solution but the problem isn't clear. The site you're talking about is yours or you want to inject this trigger event from outside? Do you want this trigger to be injected every time?
If it's just a one-night stand you can use the browser console but if it's not you could be interested in developing an add-on or a greasemonkey extention.
Update: Yo can use eventghost, specifically the window plugin http://www.eventghost.org/docs/pluginlist.html, to trigger a keypress on firefox. Now you have to inject a javascript event handler in the page every time you visit it and most of the work is done.
Update 2:
Here's the basic add-on, ;) have fun
var self = require('sdk/self');
exports.main = function() {
require('sdk/page-mod').PageMod({
include: '*.org',
contentScript: 'document.onkeypress = function (e) {console.log(e.which);}'
});
}
To use this thing download the cfx-tools from the mozilla site (sorry I can't post more than 2 links) follow the first tutorial ( be sure to read how to use the cfx tools) and when you're ready use the code I posted above.
replace the "include" value with the name of the site of your interest
Replace console.log(e.which) with your code
Last suggestion:
document.onkeypress = function (e) { if(e.which == 49){ /* trigger my function if I press 1*/}}
Bye
OK ! I finally created an AutoHotkey script and Chrome because :
I met focus problems with Javascript injection when Flash was full screen
Chrome accepts javascript commands typed in Omnibox
Here's how the script manages a channel change request :
Press Escape to exit full screen
Click in a blank zone of the webpage to be sure it gains focus
Press F6 to activate Omnibox
Past Javascript code needed to change channel
Click in the flash video area
Press F to return full screen
I don't paste the script here because it's long and Stack Overflow code parser really don't like AutoHotkey code ! Just ask if you want it.
#EdoPut suggestion is way cleaner, but it didn't solved the focus problem when Flash went full screen. Anyway thanks again EdoPut for your efforts.
I need to have a button that I can add to a toolbar that is written in javascript and has access to the document object of a webpage. I tried to use Custom Buttons, but calling document.documentElement.innerHTML returned something other than the current webpage. Is there some other method of doing this or another extension that supports this?
I used to be able to accomplish this by making a bookmark with the url javascript:[some code] but firefox has since removed that feature.
Link to Custom Buttons: https://addons.mozilla.org/En-us/firefox/addon/custom-buttons/
Just tried with the "Custom Buttons" add-on you mentioned:
document.commandDispatcher.focusedWindow.document.getElementById("foo")
works in Firefox 29.
after much research I've been trying to find a code that not only captures popup links in the webbrowser for it to navigate in, but also works on javascript codes that open new windows or popups.
i tried using the webbrowser1_newwindow event with the following code (and works great)
' prevent opening a new window
e.Cancel = True
WBAccountVirgin.Navigate(e.Url.ToString)
but it doesn't work with javascript code using:
javascript:newPopup
i managed to remove the javascript code as a string and just navigate to that and also works but not every time.
So here's the question:
What code can i use that works with every sort of newwindow event or popup where i don't need to provide the url beforehand of that popup? Also that works with javascript popup codes..
I've seen that most places people offer the solution of using the NewWindow2 and NewWindow3 event but that isn't even part of the pre-loaded Webbrowser control which i am using. I don't want to use the Microsoft Webbrowser that i have to import. I want to use the WebBrowser Control which is already loaded.
I want to use Google Mailhide to hide my email address from spam bots.
[Check the same code on Pastebin]
<p>Contact me: robin...#gmail.com</p>
As you can see, the onclick event is being used to execute some JavaScript code -- essential for opening the link in a popup window. But it doesn't seem to be working as I am simply being taken to the link itself.
Is something wrong with the JavaScript code?
(PS: I am on Kubuntu Linux and using Chrome.)
<p>geek...#gmail.com</p>
The javascript part isn't in there. Something is wrong.