how to link java script code to a web page such as mail.google.com?
I m new to javascript,i want to create an add on for mozilla browser which ll install in firefox n modify the web page on the fly,store the changes for next time visit.Plz Help
Also tell me how to link this code to the browser ?
But the thing is i want this script to execute whenever i use gmail on a browser, choice of browser can be restricted.Thats not the issue
Since i wanted to run the code so i made it as HTML,but in reality i m tryin somethin else
PLZ HELP
// ==UserScript==
// @name Alert
// @namespace testing
// @include http://www.google.com.au/
// ==/UserScript==
// will not be accessible later because exists in different scope
var test = function () {
alert("Hello world");
}
var div = document.createElement('div');
div.innerHTML = "Something: " + "<input type='text' value='testing' />";
var go = document.createElement('input');
go.type = "button";
go.value = "go";
go.addEventListener("click", test, true); // only way to attach events
document.body.appendChild(div);
div.appendChild(go);
var scriptElement = document.createElement('script');
scriptElement.type = 'text/javascript';
scriptElement.innerHTML ='function checkForvalue() { \
var testing = document.getElementById("compose_editorArea"); \
var doc = testing.contentDocument; \
alert(doc);}';
/*scriptElement.innerHTML ='function checkForvalue() { alert("WELCOME TO CAIR"); }';*/
document.getElementsByTagName("head")[0].appendChild(scriptElement);
window.addButton = function () {
// Get the location on the page where you want to create the button
var targetDiv = document.getElementById('navcontainer');
// Create a div to surround the button
var newDiv = document.createElement('div');
newDiv.setAttribute('id', 'autoCheckOrder');
// Create the button and set its attributes
var inputButton = document.createElement('input');
inputButton.name = 'autoCheckOrderButton';
inputButton.type = 'button';
inputButton.value = 'SendEN';
inputButton.setAttribute("onclick", "checkForvalue();");
// Append the button to the div
newDiv.appendChild(inputButton);
targetDiv.appendChild(newDiv);
}
addButton();
I m trying to read the contents of compose box in yahoo mail on pressing a new button which is added by this code.
The thing is it is an iframe,so m gettin error as
object HTMLDocument
where as if i use to read content of text area then it is successful
the code then used is
scriptElement.innerHTML ='function checkForvalue() { \
var testing = document.getElementById("to").value; \
alert(testing);}';
Please help,I want to read as well as write the contents of compose box on click of a button
Bookmarks