Change IE title from bookmarklet - javascript

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.

Related

Chrome browser and Javascript alert box

My web application uses alert and confirm boxes to display information when a link is clicked.
All browsers display these boxes properly except for Chrome. When I click on a link in Chrome, all I get is the box displayed with one word "Javascript" inside.
It has to work correctly in all browsers, even if the box displayed is constructed a little different in each. It barely works in IE but it does work and if you are going to use that crippled excuse for a browser, you deserve it! ;)
I didn't think this simple problem required a demo in jsfiddle and every one knows what an alert or confirm box looks like, nevertheless if someone needs more clarification please don't just not answer at all, but let me know.
Thanks,
Paul
well alert box is a browser component, therefore all browser vendor uses their own implementation. Since you want same result on all browser, the best you can do is use your own code to produce the result like using modalpopup which will be static around all browser
If you want to ensure cross platform and cross browser compatibility i would use something like:
jQuery Dialogs
Would be alot handier and ensure it looks/works the same everywhere.
Please note jQuery is just an example and any other alert/confirm like JavaScript/CSS would do the job just don't rely on the browser!
Please also note that browsers can change there implementation at any time leaving you stuck if you dont use your own!

Window.open opening tab instead of popup in Opera?

I'm simply opening a popup from JavaScript with the settings you can see in the code. Works fine in Firefox. In Opera it's opening it in a new tab instead. Why?
Here's a JSFiddle:
http://jsfiddle.net/hafWs/3/
The number of parameters doesn't seem to make a difference. Either work in Firefox and IE8. (Don't have IE9 or Chrome to test right now.)
I tried googling... can't find anything. I don't even see anything here that mentions it, yet it's clearly working in their examples: http://www.quirksmode.org/js/popup.html
Thank you for any help.
There is problem with spaces in options param:
window.showPopup = function(){
window.open(
'http://placekitten.com/600/500',
'thePopup',
'width=600,height=500' /* <------- Look, no spaces and works */
);
}
It is still a tab, but with different dimensions. So, it looks kinda as popup.
This is controlled by the browser itself (preferences) and cannot be changed from JavaScript.
NOTE: I've seen some posts that say you can determine whether the window opens in a tab or as a new window based on the parameters that you pass the window.open function. I have never seen this work consistently.

Javascript slider not showing in IE9

We have an automatic slider on this website, http://www.realcapfinancial.com and it has been working on all browsers. IE9 doesnt seem to work. It comes up with and error, no object line 298... character 2 etc. I forget what it says but I can't check it again since I'm at work using a mac.
Any help is perfect, thank you
The element with id calcclick is only added after the Resources tab is click. However, this element is already adressed (on line 298) on page load.

Why does CodeMirror not work on Ipad?

Greetings,
http://marijn.haverbeke.nl/codemirror/jstest.html works on Safari on PC, but not on an Ipad. Which is a shame, since I wanted to use it for an app. My question is not only why does it not work, but how should I go about analyzing things that break on Ipad Safari ?
T.
CodeMirror2 works mostly fine on an iPad;
You can add text, remove text and move the cursor around.
You can however not hilite words and cut / copy / paste (as of today 2012-06-27).
The editor in CodeMirror is actually an iframe, and not a native text input form element. The problem here I suspect is that the browser on the iPad does not know if the keyboard should be activated because some DOM element has key events bound to it.
To do that, Safari would have to analyze the source code to deduce key bindings and when should the keyboard be activated - which sound hugely problematic to me.
perhaps it used an iframe in the past, but I have codemirror on my website now and I see no iframes at all contained inside it.
this is almost one year later though, so perhaps now the situation has changed.

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()?

Categories