Can I run my own javascript code in a browser when viewing a page?
For example I have page index.html. In that I want to run this javascript function
function myFunction()
{
alert("Say Hi");
}
I want to call this function through some browser interface because I don't have access to the source code of the web.
Yes. Just how depends on which browser you're using:
For Chrome and Safari you'll use the built-in Web Inspector—see the instructions on this page.
Firefox has the built-in Web Console, but the more advanced add-on Firebug is very popular.
The Internet Explorer equivalent is Developer Tools, which you can launch with F12.
You can use a bookmarklet, the javascript console or a browser plugin to run your own code in an already loaded page.
Greasemonkey is a browser plugin for Firefox that provides a framework for running your own javascript code in other web pages that are already loaded.
You can either simply type it into the JavaScript console for your browser, or for trivial things, you can use the javascript: protocol handler.
One of the first links when searching on google - Get Started With Greasemonkey
Related
Is it possible to force a JavaScript to run using code (c#) in Chrome Incognito?
Cause when I tried to run certain JS in normal Chrome, it works normally. But once I switch to Chrome Incognito, the JavaScript is no longer working.
*Note: I do not want to make changes to settings in Chrome
You can't control the browser from the server side, but you may do that in the client's side with the JavaScript function windows.create(), it accepts an optional incognito parameter, see MDN web docs.
Example: windows.create({"url": url, "incognito": true});
The following is the code I used to launch qtp, It is working well with IE but not in chrome.
What are the changes I shd Make to open through Chrome
var qtApp = new ActiveXObject("QuickTest.Application");
qtApp.Launch(); // Start QuickTest
qtApp.Visible = true;
Microsoft's VBScript is integrated with COM and UFT also exposes a COM interface, this is why you were able to launch UFT from HTML using VBScript. However VBScript is not supported by Chrome and JavaScript is not integrated with COM (at least not Chrome's JavaScript).
Therefore I don't think there's a simple way to launch UFT from an HTML page using Chrome. It is possible if you write a Chrome Extension but I don't think this is worth the trouble.
One way to do it will be to create an ASP.Net website, ASP.net will support opening UFT using the COM interfaces. I am doing the same thing for ALM's OTA API.
I have a web application that consists mostly of JavaScript and I know the only browser thats ever going to open that web page is going to be Chrome.
Is there a way for my JavaScript to realize that the developer console of Chrome has been opened i.e. the Chrome JavaScript debugger has attached?
I tried using phantomjs to load a website
http://kissanime.com/Anime/Flag/Episode-001
But this website have some block even if I use phantomjs useragent as mozilla firefox, then I try using lynx browser but its unable to render javascript in the page, thus I decided to use SpiderMonkey which said to be able to render webpage with javascript and act as a browser.
But how to use SpiderMonkey to curl the site and output the content as 1.html
Have a look at http://slimerjs.org it's a Phantomjs port on Gecko.
I write a HTML page and I want call a Chrome API(eg tts) with a Javascript function which in my HTML page.
BTW: I don't want to create a Chrome Extensions, just want run as a web app.
Is that possible ? If can be possible, how do I do ?
With very few exceptions, chrome.* APIs can only be used within the context of a chrome extension. There are a few exceptions, but probably none that you want. To see them, press F12, type chrome into the prompt, and click to expand the returned opject.