Back button in safari browser broken - javascript

I've read a couple of questions here about back buttons being incompatible with Safari , but I didn't encounter my specific type of problem. Right now I have
<a id="back_btn" onclick="" href="javascript:Application.goBack();void(0);">
What I try to accomplish is having a back button. This works on all devices except Safari (new versions, for instance I am testing on 9.0). I've already tried with:
<a id="back_btn" onclick="" href="javascript:history.go(-1);">
and many other variations I've read about in other similar questions but they doesn't seem to work either.
Now here is the catch. All this is happening in iframe and url is not changing at all (while the content does (as on other browsers) ). I've also noticed that first time I hit the button it does something, because the back button from browser becomes active , but the thing is that the content is not changed. Its like it tries to go back (and probably does) , but it doesn't change the content of the iframe.
EDIT : I might have found whats the problem , but I am not entirely sure how I can workaround to fix it.
The thing is that I have a client that opens my site with domain url = X in a iframe. But the client's url is different from mine. Once I open my iframe back button works as intended. Can somebody explain whats going on here?

see manual http://www.w3schools.com/jsref/met_his_back.asp
<button onclick="goBack()">Go Back</button>
<script>
function goBack() {
window.history.back();
}
</script>

Related

Opening browser's home page in other than IIE

I'm writing a bit of code to display an EU Cookie notification.
If the visitor does not accept the use of cookies, I want to take them somewhere else. My first thought was to take them to the browser's home page.
I found a way to do it in IE - I have been told that the method on that page is for IE 10 or less.
I have not found a way to do so in other browsers.
If this turns out to be more trouble than it is worth, I'll take them somewhere via a specific URL, such as www.google.com
Does anyone know of the method to accomplish the same thing in browsers such as Firefox, Safari, Chrome, etc?
Most browsers implement an address that will point to the home page. You should be able to redirect the user to the proper location after you figure out their browser.
For Chrome you can link them to about:newtab, which may be different from the home page, but it is probably the closest you will find. The actual homepage button is not implemented in Javascript and does not use a URL.
For Firefox you can link to about:home.
For Opera you can link to opera:speeddial. (I did not test this one, if someone wants to I'll update)
The documentation you linked to claims to be obsolete after IE10. I think you can link to about:home on IE same as Firefox if your solution isn't working afer IE10. (I did not test this one, if someone wants to I'll update).

Why doesnt firefox redirect after printing?

First of all, this is a new problem which happens since a few weeks. Currently I'm using FF Version 37.
On multiple sites of our Intranet we use links, that look like this
<a href='some_page.php' onclick='window.print()'>Print</a>
The printing part works fine and normally after the printing is done, the page changes its location. This doesn't happen anymore. We found a temporary workaround, that redirects the page via JavaScript after a timeout of a few seconds. It is hard to find a timeout, that isn't too long for a good user experience and isn't too short so that the redirect doesn't fire.
Does anyone know a solution for this, except rolling back to an older version of Firefox or changing the browser entirely?
This might help
<a href='some_page.php' onclick='doPrint(); return false;'>Print</a>
function doPrint() {
window.print();
document.location.href = "some_page.php";
}
It sounds like a bug if it was redirecting for you before, I'd suggest logging a ticket with Firefox with examples

Images don't display in ie9 when inserted using ajax and innerHTML, until users right clicks on and clicks "Show Pictures"

I was upgrading a wesbite to work with IE9 (I really hate IE), and after much fiddling it all finally worked, except that when inserting html into the page using code like the below, none of the pictures would display.
$("#div").innerHTML(htmlToInsertWithImgTags);
The inserted HTML looked a little like this:
If you right clicked on any of the img's and then clicked on "Show Pictures", they all magically appeared, like below:
This happens due to a trust setting in Internet Explorer, but if the image's you want to insert are already present on the web page, then internet explorer trusts the new content and shows the pictures.
So we got round this problem but adding code like the following (I'm aware this isn't good html) to the static part of the page, and then when this picture was inserted using Ajax and innerHTML eveything worked as you would expect.
<img url="redcircle.gif" style="display:none" />

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.

Set default home page in JavaScript

How do I create a link to set the user's home page to my URL?
As some people have already answered, it used to be possible in internet explorer (prior to IE 7 I believe, could be wrong though) using something similar to
document.setHomePage('www.example.com');
I don't think any browser supports it anymore though. However, I would definitely try to convince you to do otherwise. Most people won't like having their settings automatically changed, even if it's triggered by a mouse click or other action. It's also quite likely that overzealous 'protection' programs will jump all over it and stamp it as a malicious attack.
As far as I know it's just possible in Internet Explorer
Make my Page your
<a href="javascript:history.go(0)" onClick="this.style.behavior='url(#default#homepage)';
this.setHomePage('http://www.test.de');">Startpage</a>.
I assume you mean put a link in your page to make it the browser homepage? In IE you can do something like:
this.setHomePage('http://www.mysite.com');
I don't think that works in Firefox though.

Categories