Make address bar read only in window - javascript

I am opening a window as follows :
window.open(url, "_blank", 'toolbar=yes,menubar=no,dialog=yes,maximize=no,top=20,left=165,scrollbars=yes,width=' + width + ',height=' + height + "'");
Here I need to make the address bar as read only. I was looking at this answer but this disables the address bar. However I want it read only.

You can't do that in any browser, use sessions instead to pass values from one page to another so that no one can modify it.
or you can also implement CrossPagePostback concept.

It can be done in modern browser. Modern no longer hide the URL bar when location is set to 0. Instead they render it as read only.
The answer here states the behavior of IE7 regarding this,
in IE7 and later, location=no simply hides the back/forward/stop
navigation buttons, and makes the address bar read-only.
Firefox also behaves the same way. Here is the official documentation,
In Firefox 3, dom.disable_window_open_feature.location now defaults to
true, forcing the presence of the Location Bar much like in IE7. See
bug 337344 for more information.
I have also tested with Chrome and it also behaves the same way.
So the short answer is "Set location=0 and you can make the URL bar read only".

Related

Remove Address bar from popup window using Javascript

Is it applicable to remove the address bar from a popup window using javascript
ex:
window.open(url, 'liveMatches', 'width=720,height=800,toolbar=0,location=0, directories=0, status=0, menubar=0');
please advice,
use jquery ui (http://jqueryui.com/demos/dialog/)
or perhaps
window.open(url,'liveMatches','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=720,height=800');
actually
You cannot remove the address bar in modern browsers. That is a security measure. The user must always know what page they are on. Address bar also let user know, what type of security is on that page (HTTP or HTTPS).
Theoretically, yes. However, as with everything in Javascript, there's no guarantee that any given browser will support it or that the implementation will be consistent across browsers.
This link as well as this link indicate that the location option should control whether or not the Location/Address bar is shown. It should also have relatively good cross-browser support.

WIndow.open in Javascript

I really need your help. I am working on a pop up window
using JavaScript.
I am using the window.open(URL,name, properties);
I wanted to load a window that does not load the URL window.
I tried the location=0 and location=no setting, it seems to work
fin on Firefox but alas it is not working on IE!
In Firefox, it is not showing the location bar anymore, but in IE
the location bar is still there with the URL!
Please help. :9
tinks~
You seem to be calling the method correctly, IE most likely doesnt allow you to hide its url bar. Most browsers have user-defined preferences whether they want to allow websites to be able to hide toolbars. Popups are very susceptible to security options.
I'm afraid you'd have to live with it, if the user doesnt want you to hide the url it wont.
Not possible anymore as all modern browsers do not allow you to hide the URL in Popups anymore :)

Change IE title from bookmarklet

I am creating a JavaScript bookmarklet that dynamically updates the title bar, but it doesn't display the changes in IE (I've tried IE7 and IE8). Here's a simplified example that demonstrates my issue:
javascript:document.title='new title';alert(document.title);
Notice that the the value is updated in the alert, but not on the title bar or tab. It is working fine for me in Chrome.
It's a bug in IE. It's possible to work around it by changing the URL's fragment identifier ("hash"), which may or may not be feasible for your purpose:
javascript:document.title='foobar';location.replace('#'+new Date().getTime())
new Date().getTime() is used to get a unique number that is unlikely to be used as a name or ID anywhere in the page (so that the page does not actually scroll).
From my experience most browsers will update the new TITLE in the browser window or tab.
However it seems with IE browsers they only set it one time and then that's it - no further updates. If thats true (would love to see a solution as well) then there is no way around it.

Referring to a specific place on page

I know that in Javascript document.location.href = "#my_id" tells the browser to display the same page starting from element with id="my_id".
In this case, the address that appears in the address bar is in the following format: my_page_address#my_id
Is this the only method to refer to a specific place on a page ?
I'm looking for a method that will not show my_id in the address bar.
Most browsers implement the scrollIntoView method (MDC, MSDN) on elements. That works on IE6 and up (at least), Firefox and other Gecko-based browsers, Chrome and other WebKit-based browsers, Opera, etc.
scrollIntoView example using an element retrieved by ID:
document.getElementById("my_id").scrollIntoView();
Of course, this requires that Javascript be enabled (I'm assuming this is okay because of the Javascript tag on the question :-) ).
You can also scroll to specific coordinates on the page using window.scrollTo.
Have you tried document.getElementbyId("my_id").scrollIntoView()?

Script to hide status bar messages in Firefox, IE, Opera, Safari?

Currently I am using this:
OnMouseOver="window.status='';return true;"
for:
<asp:LinkButton ID="lnkCategory" runat="server" onMouseOver="window.status='' ; return true;" onMouseOut="window.status='';" oncontextmenu="window.status=''; return true;">
This works fine in IE but not in Firefox.
How can I be able to change this?
I want to disable the status bar messages for the linkbutton.
Disabling the status bar message is evil. Don't do it.
By default, this is turned off in Firefox. You'd have to force your users to change a config setting to make this work.
One alternative you could try is swapping out the value href with an empty string on hover, then navigating the user to the link's href on click. This is considered a bad thing to do though. It's not bulletproof. Users could still tab to the link or do other things that should trigger a link's default behavior.
As karim79 said though, don't do it.
Disabling an expected browser behaviour is usually a bad idea. consider if you really need to do this.
I would caution against this - as others have posted it's expected behaviour.
On a personal note I use the status bar message to check that the link is really going where the page claims. If I found this on a page I'd be highly suspicious of the motives behind the site.
In Firefox, the user can control what a script is allowed to do. And like it says this post, the option is turned off by default:
Firefox settings for javascript http://img44.imageshack.us/img44/6683/61224673.jpg
Edit: So, there's not much you can do there, as you won't be able to manipulate browser settings with JavaScript code.
Some folks like to see messages on their Status Bar. Some don't. Some programmers cover all the bases by including Tool Tips and Status Bar messages in their A tags. Some don't. Some abuse the daylights out of it (eg, scrolling blinkers) which is likely why FF resorted to putting it under User control; where it should be.
Ethical issues aside, don't worry about it. The link text should be clear enough; the additional text in the Tool Tips and Status Bar message should only expand upon that.
For example, if the link text reads 'Home' then the Tool Tip and Status Bar (as you like) should read something like 'Click here to return to Home page.'
The side benefit is that some 'screen readers' for the sight impaired are able to use the additional text in the A tag (although once again everyone seems to have gone their own way on this so, again, covering all the bases seems prudent).

Categories