setTimeout window.location keeps on doing over and over - settimeout

I'm creating mobile page that has video player div in it.
And I'm trying to make it autoplay when someone visits the page.
So I tried this with settimeout function
My code is
javascript
setTimeout(function(){
window.location = $('#play').attr('href');
}, 2000);
html
<a id="play" href="<?=$data['video']?>">
I'm trying to play a video after 2sec when page is loaded.
but when I close the video and come back to the previous page, it loads the video again..
This keeps on going forever...
Is there any way to stop this?
And is there any other better way to autoplay the video other than the method I used?
The video is page. But there is nothing but a video. And when I click the link it gets large and plays by the player in the mobile device.

When you set window.location it takes you to the page with the video, then when you go back it starts the setTimeout again. The only way to make it work is to go at it from another route. If you need to use the href of the a tag then I would put the video in an iframe and when clicking on the link, show the iframe and set the source of the iframe.

Related

how can show silder look when navigate one html page another in phonegap?

Right now I am developing PhoneGap app all functionality are successfully done which what client need but in my PhoneGap app I am using multiple html pages on click of one button index.html it will naviagte to another html but client need silder look when naviagte one page to another page..
Code is:
<li><a onclick="callFestvialinfo()"><img src="images/festival_info_button.png" width="123" height="123" alt="" /></a></li>
function callFestvialinfo()
{
window.location = "festival_info.html";
}
it will navigate festival_info.html normally but client need silder look from index to festival_info.html and festival_info.html to index when onclick back.
You can check this out. A very light weight solution to page transitions.
http://www.fasw.ws/faswwp/non-jquery-page-transitions-lightweight/

How to trigger camera from a remote html page loaded in childbrowser in ios ?

I need to access camera from a remote html page. I load this html page through child browser . Need to open camera or any native view on a button click on html file..
No sure if this is the best/most elegant possibility, but it should work:
By click on button load an specific URL.
The UIWebView has delegate methods to inform you, when a page finished loading.
In the – webViewDidFinishLoad: method check if the loaded URL was your specific button URL, if YES show camera/any other native view.

How to play sound and view pictures with Fancybox and the same time?

My goal is to allow someone to view several images and play, pause,
stop an audio file that will play when someone views the images.
Deliverable: multiple images that scroll to the next picture using
fancybox navigation and an audio player at the bottom that plays a
single audio clip.
I think I probably need to add a div at the bottom of Fancybox and
then embed my player. What's the proper method? I'm a bit new with JQuery and
Fancybox :(
try these API options instead of onComplete and onClosed
'titlePosition' : 'inside',
'titleFormat' : function(title) {
return '<span>'+title+'<br /><embed style="position:absolute;" src="test_song.mp3" type="audio/mpeg" controller="false" pluginspage="http://www.apple.com/quicktime/download/" width="1" height="1" /></span>';
}
of course, check that the embed part is correct (I just copy/paste from your code) ... you may test it as a normal html embed in your page.
NOTE: this is for fancybox v1.3.x

Prevent iPhones webkit from opening a new browser window (and thus exiting fullscreen) when clicking an `rel="external"` link

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.

How to close a iPad webapp and open safari?

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