I have a very strange error. I have an webpage that runs in Appmode (when you add to homescreen on iOS). I have one A element that transfer to another page in the same domain (test2.html). If I click on it, the appmode is quited and a new browser window opens.
However if I make a location.href = 'test2.html' it works. And now the strange part, on test2.html I just have one A element with href="test1.html", and now it works.
I have a thesis that every link will work in your own domain if you sometime have done a location.href before clicking any other link.
My test case:
Test2.html
Test1
<script>
function transfer(){
location.href = "test1.html";
}
</script>
Test1.html
Test2
You can change Test2 so it similar to Test1 and just change the href and it will broke.
I really have no ide why this is happening. Why does it work just after you have done a location.href in the same domain?
I've had exactly the same problem. For now, I solved it simply by making my link return false:
<a href='#' onclick='doSomething(); return false;'>test</a>
EDIT: This seems like a better answer: iPhone Safari Web App opens links in new window
Related
my GWT app is designed to be multipage. And separated into modules. So far all other modules works, except for my 'login' module.
I don't understand why when I access http://127.0.0.1:8888/login.html?gwt.codesvr=127.0.0.1:9997 I get a blank page.
LoginEntryPoint:
public void onModuleLoad() {
GWT.log("Loading module");
if (!Window.Location.getPath().toLowerCase().endsWith("login.html")) {
return;
}
RootPanel.get().add(new Button("Test"));
}
And in the login.html file:
<script type="text/javascript" language="javascript" src="login/login.nocache.js"></script>
and finally in the Login.gwt.xml:
<entry-point class='com.mygwtapp.client.LoginEntryPoint' />
How to fix this kind of situation?
Make sure also when you compile the project Remember to add the new module to be compiled
Right Click on the Project >> Google >> Gwt Compile >> Add (add your new module)
Does your log statement happen? If not, is the login.cache.js file even loading (use firebug or the like to check)? If so, can you set a breakpoint on that log statement and step forward, see where it gets to?
And is there anything shown when you run in web mode?
If the login.nocache.js isn't loading, make sure you added rename-to="login" in the module tag, make sure it is actually being compiled, etc
This problem was happening to me, and I figured out that it was all because I had Buttons in a FormPanel. As soon as I removed them from the FormPanel everything showed up again. I am not sure where exactly you were sticking the button up there, but you might want to try removing the button out of the equation, trying another type of panel and some text, and see if it shows up without the button present.
If you are running in hosted mode, this if if (!Window.Location.getPath().toLowerCase().endsWith("login.html")) { is true, so no button should appear. Try changing the "endsWith" by "contains" method
Opening my mobile webpage from my homescreen (after adding it to my homescreen), it starts in fullscreen mode, so far so good.
After logging in (form/submitbutton), the 'app' is still in fullscreen mode, which is also the desired result.
Now, when I click a link that has the rel="external" attribute, webkit opens a new window in Safari, so it exits the fullscreen 'app' I started from my homscreen, I would like it to stay in fullscreen mode.
data-ajax="false" has te same result. Removing data-ajax="false" and rel="external" will not exit fullscreen, but this way you can't link to a multi-page document (1 document with different data-role="page").
Does anyone has the same problem, or even better, a solution?
I do not really care about the transitions, I just want the webpage to remain in fullscreen mode, (the user has to log in again when the new window has opened).
iPhone 3gs
M_webkit / 5.0.2
Why not create a script that pulls out the href and goes to the new url via javascript.
If you use jQuery it's as simple as:
$("a[rel='external']").bind("click",
function() {
if (this.href) {
location.href = this.href;
return false;
}
});
Without jquery you'll need to use object detection and attach a click event to it with the same logic inside the anonymous function above.
I'm using fancybox with ajax request to open multilpe fancybox instances on same page:
This is html code:
User
and this is Javascript i've used:
<script type="text/javascript">
$(document).ready(function()
{
$(".comment_button_fancy").click(function(){
var element = $(this);
var Ide = element.attr("id");
$("#"+Ide).fancybox();
return false;});});
</script>
Everything could be ok, just 1 problem... first time i load the page, i need to click 2 times over "User" to open fancybox...
If i open fancybox and then i close it, the second time i can click just 1 time...
why?
Thanks
The first click registers the event to the DOM, and the second (and subsequent ones) show the Fancybox.
If using multiple Fancyboxes, you should avoid using ID's like you have there and change it to classes. Not sure why you've got all that code to launch the fancybox, when this should work:
$(".comment_button_fancy").fancybox();
This will Fancybox all elements with the class "comment_button_fancy" and should fix your two-clicks issue. You don't need to put a 'click' event handler around the Fancybox code, as it inherently has that event attached to it.
I'm working on a webapp for iPad. What I want is provide a "save & quit" option. When the user presses the quit button, I safely update my database and show a screen who thanks the user for using the webapp.
What I want to do now is actually close the webapp. As window.close(); doesn't seems to work I have found a workaround with links.
Clicking on a link in a webapp closes the fullscreen app and opens safari. So far I tried to embed an hidden link in my mage and trigger it with link.onclick(); but it doesn't work, and document.location= doesn't open safari.
Here's the HTML example:
<body onload="leave();">
Modifications saved, goodbye!
<a id="goodbye" href="www.mahsite.com" style="display:none;"> </a>
And the JS:
function leave() {
window.close();//Doesn't work
window.setTimeout(function e(){document.getElementById('goodbye').onclick();},1000);
return true;
}
Can someone give me an idea? I'm aware that the onclick() won't work unless I have a onclick handler attached to my link, but I don't have any other idea.
Try
self.close();
or
self.window.close();
I am building a web page and I have included Facebook's Like button. Works great in all browsers but not in Firefox. When clicked in Firefox, it creates an endless loop of opening and closing a facebook login window. This is a known issue that Facebook isn't looking like it will correct anytime soon.
Can anyone tell me what code I might write to hide the like button (or a div containing the like button) from Firefox only? I've never written code to detect a browser and then have my site function a certain way. Not a javascript guru here. Thanks!
You can do this using the navigator javascript object, but it sounds like you have deeper problems if the facebook like button is causing an endless loop of window loads. You most probably have other errors in your code. The button should work fine in firefox.
Here's how to text for firefox using the navigator object,
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
// user using firefox
}
This code parses the userAgent string, the string that defines the user's browser, of the navigator object. It looks for a string of the format Firefox/x.x or Firefox x.x.
This should work for you
<div id="likeDiv">
my div
</div>
<script>
if (navigator.userAgent.indexOf("Firefox")!=-1)
{
// Remove the element from the dom
var Node1 = document.getElementById('likeDiv');
Node1.removeChild(Node1.childNodes[0]);
}
</script>
Hope this helps