How to use currentURI to get active tab url of firefox browser - javascript

I am looking for to fetch current tab (loaded or blank ) URL of Firefox browser.
How to acheive this ? using currentURI property in javascript.
Thanks a lot,
-Pravin

Is your code running inside an addon? You could use:
gBrowser.currentURI.spec

Related

javascript window.location.href doesn't work with IDN-hebrew domain

Example, we have a page:
https://www.facebook.com/חמישה-נוסעים-398064063958835/ (if you open in chrome)
https://www.facebook.com/%D7%97%D7%9E%D7%99%D7%A9%D7%94-%D7%A0%D7%95%D7%A1%D7%A2%D7%99%D7%9D-398064063958835/ (same url if you open in IE).
I need a javascript that will return me https://www.facebook.com/חמישה-נוסעים-398064063958835/ url. This script I'll use only in Chrome browser.
At the moment window.location.href returns the path like IE shows.
Use decodeURIComponent(window.location.href)

Opening url in new tab from dropdown select

I have this and i can't get it to work on Safari for OS X (Safari 8.0). It works on Firefox and Chrome but i simply cannot get it to work in Safari.
function myChangeHandler()
{
window.open(this.options[this.selectedIndex].getAttribute('value'), '_blank');
this.form.submit();
}
What am i missing?
Thanks
I'm not sure what doesn't work since there is no specific problem that is posted but I'm guessing it's the window.open()?
I found this article
window.open(url, '_blank'); not working on iMac/Safari
it might be the one you were looking for.
From:
Kelly J Andrews
The standard window.open() JavaScript method cannot be used to open a new tab and window from a global HTML file or an extension bar. Instead, the global file and extension bars have access to the SafariApplication, SafariBrowserWindow, and SafariBrowserTab classes, whose methods and properties allow you to work with windows and tabs.
It goes on to explain how you can use
var newTab = safari.self.browserWindow.openTab();

Javascript window.open() toolbar=no not functioning

I am attempting to open an html file in firefox with minimal extras (toolbars, menubars, addressbar, etc). Just the html contents of the webpage, and nothing else. I want to be able to do this within linux from the terminal. I also have to do it in such a way that it works across multiple linux machines running the same version of firefox. So this removes any possibility of using a profile. I was hoping there would be a simple parameter to firefox that would allow me to turn these settings off. I dont believe there is.
The only possibility I have found is through javascript's window.open. It appears the parameter specs to window.open arent even functioning in firefox 1.5.0.9. I have read that some of them were removed in firefox 3.0+, but have not found anything regarding the version I am using, 1.5.0.9.
This is what I am using to open my .html file using windows.open...
test.html:
<html>
<body>
<script>
window.open('./rel_notes.html','_self','toolbar=no,menubar=no')
</script>
</body>
</html>
And then just running 'firefox test.html' from the terminal.
Both the toolbar and menubar still appear when I do this. What am I doing wrong? Is there a easier way to do this?
If your browser settings allow pop-ups without notifications from X source (localhost i presume?) then the following might work:
window.open('./rel_notes.html',null,'menubar=no,toolbar=no');
window.open('','_self',''); //this is needed to prevent IE from asking about closing the window.
setTimeout('self.close();',500);
Taken from a link in the link bungdito gave me:
After a window is opened, JavaScript can't be used to change the features.
So by opening test.html, and then using window.open on _self, I am trying to adjust features to a window that has already been opened, using javascript.
Source: https://developer.mozilla.org/en-US/docs/DOM/window.open

How to view javascript generated html for Internet Explorer?

I am looking for a way in IE to view the html source generated from jQuery code.
Ex.
HTML:
<div id="myDiv"></div>
jquery:
var wrapper = $("myDiv");
var generated = $("<div>Hello world</div>");
wrapper.append(generated);
I'd like to be able to examine and hopefully tweak the source generated by appending the generated element, not in Chrome or Firefox, but in IE 8 (where the problem is). I think that IE Developer Tools only shows the downloaded source, not what is generated.
Thanks.
Try going to the HTML tab in IE developer tools and press the refresh icon (next to the save icon), it will show the latest DOM.
Example:
Go to script tab and do:
document.body.appendChild( document.createElement("div") );
Then go to the HTML tab and hit the refresh icon and open the body tag, it should show the appended div now.
I recommend Firebug Lite - http://getfirebug.com/firebuglite (it's Firebug for IE, sort of)
You should get Firebug Lite. You can check the code that jQuery does and much more.
Anyway, I recommend that you put Google Chrome Frame compatibility on your site, it will eliminate plenty of problems with your site (with the people that have Google Chrome Frame installed).

change url of tab javascript firefox extension

I am trying to change the url of a currently open tab in javascript firefox extension
Any pointers please?
I believe it's "gbrowser.loadURI()". Try reading this page on MDC about interacting with the global variable gBrowser, and here about the loadURI method.
The mozilla doc mentioned by TML has sample code for this under "Reusing by other criteria", but it's broken. The corresponding talk page says to add this line to fix it:
tabbrowser.loadURI(url, tabbrowser.currentURI, "UTF-8");
However, if you've already got the tab object (say from calling addTab earlier) then I think it's simpler to do:
gBrowser.selectedTab = mytab;
gBrowser.loadURI(myurl);
I don't see any way to change the URL of a tab which is NOT selected, but that would be nice - I hate stealing focus.
UPDATE: here's how you do it w/o selecting the tab. Simple:
gBrowser.getBrowserForTab(mytab).loadURI(myurl);

Categories

Resources