With JQuery Mobile and MVC3 ASP.NET, on an iPad, created a home screen bookmark.
The app pulls up with no problems, it does not show safari's bar.
I login to my app and click a link, THE LINK OPENS SAFARI, NOT INTENDED.
My question is how to prevent the clicked link from opening outside of my bookmarked app?
I've tried:
$(document).bind("pageinit", function () {
$("a").click(function (e) {
e.preventDefault();
$.mobile.changePage($(this).attr('href'));
});
});
The code above seems like it should work based on the docs from jquery mobile.
When I click the link/button the link/button highlights but no error or page load.
Also, another question is why when I leave the app and come back the session dies?
iOS will treat links where you have stipulated data-ajax="false" as a link that should be opened by Safari. I had the same problem in my MVC site that is using jQueryMobile. I found this post very helpful and the following piece of code works very well in my application.
$("a[data-ajax='false']").live("click", function (event) {
if (this.href) {
event.preventDefault();
location.href = this.href;
return false;
}
});
Is this webpage you are linking to being packaged with the app? You need to do so. The app cannot find it and goes out to the browser.
The code itself is fine.
http://jsfiddle.net/m35BU/5/
Session variables are stored on a server...are you talking about a javascript cookie?
If so, unless you set an expiration date for the cookie (mktime()+3600*7 for 7 days) or whatever, it will expire when the app is closed.
Related
When recaptcha v2 laods on any page of this site, in Chrome, you have to press the browser back button 3 times to return to the previous page:
https://fromhere.to/6m4sh
Firefox, Opera and Edge are fine. This only happens in Chrome.
In the network tab of browser tools, clicking the back button shows a lot of requests to recaptcha and nothing happens. On the 3rd click, you finally get back to the previous page.
As far as I am aware, this only started happening today.
I'm using Version 67.0.3396.99 (Official Build) (64-bit).
Can anyone see what's going on?
UPDATE:
I found another site using the same theme (Rosa) and it has the same problem so that seems to be the issue.
This turned out to be unrelated to recaptcha and an issue with the Wordpress Rosa theme.
The function causing the problem in the theme's main.js file:
function initVideos() {
var videos = $('iframe, video');
// Figure out and save aspect ratio for each video
videos.each(function() {
$(this).data('aspectRatio', this.width / this.height)
// and remove the hard coded width/height
.removeAttr('height')
.removeAttr('width');
});
// Firefox Opacity Video Hack
$('iframe').each(function(){
var url = $(this).attr("src");
if ( !empty(url) )
$(this).attr("src", setQueryParameter(url, "wmode", "transparenartt"));
});
}
There are no videos on any page of the site so I am pointing the finger at the 'Firefox Hack' which modifys any iframe with a src attribute and adds a misspelt query parameter to the end of it :).
Recaptcha loads in an iframe which is probably why I could always see the problem on a page with a form.
I'm developing an extension that needs to be triggered when a user switched videos on youtube.
I've tried to listen to load or pageshow but they are not triggered when a user is watching a video and clicks another one
var tabs = require("sdk/tabs");
tabs.on('pageshow', function(tab) {
//do something
});
Use a history pushstate listener if you want this to work with any modern webapp that changes the URL without refreshing the page. See my answer here
I'm adding a facebook share button to each post on a Wordpress (Using Facebook Share Button New plugin), it works ok for each post/page except when i'm loading them trough ajax, the result it's a normal Facebook like button but the popup (to write a comment) appears inside the button it is not expanded.
To check go to: http://iwanttobeher.com/ and then click on any face at the bottom of the page, then test the like button and you'll see what happens.
I don't know what to do, i tried to FB.XFBML.parse() after loading the content but the result is the same.
Switching to HTML5 didn't help in our case. What did was to remove the FB object just prior to new content being inserted into the page via Ajax:
delete FB;
wrapper.html(response.data);
We reload full pages via Ajax and so new page content recreates the FB object and re-initializes XFBML anyway. Not sure if this workaround would work if we reloaded only parts of the page though.
The original answer is here.
I've managed to fix it by changing the implementation to HTML5 instead Iframe or XFBML using Facebook's tool to generate like buttons: https://developers.facebook.com/docs/reference/plugins/like/
I have a problem:
I want to play a video from a full screen web app, not using html embed, but using an image banner which redirects to the video url (for example url: http://example.com/media/vid.mp4),
because this can't be done using hrefs, i'm just calling a javascript event:
HTML:
<img src='http://example.com/media/banner01.jpg' id='play_video' />
JavaScript:
<script>
$("#play_video").click(function(){
window.location = "http://example.com/media/vid.mp4";
});
</script>
But because it's just an AJAX page, once video finishes playing, the user is back to the 1st page, however, I have a unique url for each page (for social networking), but how can I inject it to the browser's history, or perhaps some other method of playing the video?
I've been through a similar thing recently, and have found jQuery.address to be a great solution. It handles changing the URL in an AJAXy way, lovely.
Of course, if your users are running in standalone full-screen mode, you'll need to implement some controls for navigating the site without the usual browser chrome.
Here is the case.
I have a website built in asp.net mvc3 with custom CMS.
Is there any way by clicking a button from cms to reload the page of the website visitors?
For example, here in stackoverflow, if an admin from the backend pressed a button my page would reload automatically (or even a lightbox would appear, or redirect me to a different page).
Can we do that?
With HTML5 you can use web workers to do this for you: http://html5demos.com/worker
Without HTML5, you can set up some basic polling code in your javascript. It would call a method on the server that would tell it whether or not to reload. You can run this every 30 seconds let's say:
$(document).ready(function(){
var doRefresh = function(){
$.get('checkForRefresh', function (data) { ... handle response ... });
};
setInterval(doRefresh, 30000);
});
And then just have your checkForRefresh server side code read a value set by that CMS button.
Forcing a reload on a button click boils down to something like this (using jQuery and javascript):
<script type="text/javascript">
$(document).ready(function() {
$('#Button1').click(function() {
location.reload();
});
});
</script>
The first answer on the following question shows two ways to refresh the page, one forcing a reload like above, and the second, much like #Milimetric describes in his answer:
Refresh (reload) a page once using jQuery?.