the script i created uses PrettyPhoto to load an ifram on which there is an upload page going on, the upload works great the image is uploaded and the url is returned back to the page for preview, but not saved into the database just yet...
so far so good, i just want to add a function that if a picture is not saved and the user hits close button it will promt to either save or dismiss which it will make an ajax call to either remove the uploaded picture or save its url into the database
does anyone have an idea how to do that? not the ajax part i have everything under control, just need to know how to prevent the prettyphoto close button from closing directly
ps: i tried the callback function but what it does it that it closes then executes, but i need the execution to be done before closing
any help would be much appreciated
thank you
you can tweak the prettyPhoto js code but that will effect all your popups, so as you found the workaround of the close function inside the iframe then that's it, you didn't have to duplicate themes and hide the close button on the its stylesheet, you could have simply let jquery do so from withing the iframe, just include this code into your iframe
<script type="text/javascript">
$(document).ready(function() {
window.parent.$('.pp_close').css('display', 'none');
});
</script>
Related
Actually this is what I'm trying to do. I have a form and when a user fills that form it goes to a thank you page where thank you message is displayed. Now what I'm trying to do is as soon as the thank you page opens a pdf file should start downloading without the user clicking anywhere on the page. I tried to find a solution by searching but almost all of them have given a solution where one link is provided and user have to click that link to download her pdf. But that is not what I want. And I want to achieve that using Javascript or jQuery only, no server side language.
A clarification:- PDF download on clicking a link is already working. What I want is PDF to download as soon as thank you page opens. I know logically this should not happen because by doing this anyone can set any number of files to be downloaded as soon as their page opens and fill your local drive. But my client wants only this thing to happen.
Calling click() for the user on an other-wise working link should do the trick:
<html>
download pdf
<script>
var link = document.getElementById("link");
link.click()
</script>
</html>
You can do it, in the HEAD tag:
<meta http-equiv="refresh" content="0; url=yourfile.pdf">
This will work also with browsers without JavaScript, and as soon as the the head tags loaded.
a working example:
See an example on github
You can use ajax to hit the url when the page loads.
EDIT: You might want to check this out https://stackoverflow.com/a/29266135/4549494
I have problem with my 2 scripts on my web page (http://obielecki.com.pl/)
I have modernizr.custom.js to resize my image by Morphing Button Concept http://tympanus.net/codrops/2014/05/12/morphing-buttons-concept.
And then i have mail sender from freelancer bootstrap template
They work just fine separated, but when i have them both i can only resize my picture.
When i try to send mail nothing is happening (no communicate).
I can't figure it out what's wrong inside this scripts, that make this kind of conflict, so i try to just remove this modernizr.custom.js after i click Send button.
I try to use jquery:
$("<script src="js/modernizr.custom.js"></script>").remove();
but i can't make it to remove script after i click button, then againt put it back after user saw or click on succes mail communicate.
Is it possible to integrate a javascript into a hyperlink? Or make it into some sort of batch script or whatnot, so when the page has loaded it calls the javascript which is a button on the page?
To explain it further:
We have this page:
http://work.acceptance.XXXX.com/XXXX_Raffle/Lists/Raffle/overview.aspx
The sharepoint page has a survey on it.
To get the "popup" window to show, so you can answer a question in the survey, you need to press a button which calls this script:
javascript:__doPostBack('ctl00$m$g_e999ab40_719f_42fb_bd61_d986f232bdd5$ctl01$ctl00$toolBarTbl$RptControls$ctl00$diidIONewItem','');
So, is it possible to somehow combine the page + the javascript, so all they have to do is press one link or alternatively, a hyperlink which goes to a file on a server which triggers all this, so they instantly get to the page + the javascript automatically pops so they dont have to press the button?
Keep in mind, when I say "hyperlink" I mean the kind of hyperlink you would see in an email. A simple link to a website or a server location.
I'm not very good at everything that has to do with programming and webdesign, but I do have access to the sharepoint, though I'd need serious guiding in how to add anything there other than simple webparts. It's SharePoint Server 2010.
Here is a picture of the button and what happens when you press it.
http://i.stack.imgur.com/gKCG5.jpg
Add an onload event to the page to get it to show the popup:
<script type="text/javascript">
window.onload = showPopup();
function showPopup() {
__doPostBack('ctl00$m$g_e999ab40_719f_42fb_bd61_d986f232bdd5$ctl01$ctl00$toolBarTbl$RptControls$ctl00$diidIONewItem','');
}
</script>
This needs to go on the page that you're linking to so that the link takes you to this page which then fires this onload. Put it before the closing tag on the page.
No. You cannot construct a URL that will load a document and then call some JavaScript.
You would have to modify the page you are linking to so it runs the JS automatically. It could look at the URL and run that function conditionally though (e.g. if (location.hash === '#foo') { ... }.)
I am currently making a temporary download page for website visitor.
The page includes a form, after the visitor fills the form up, the site will take them to the pdf download page.
In the download page, there are some pdf files download links (I am just using a tag.). However, i wanna make a onclick event to those links, once they have been clicked, the page will refresh automatically or redirect to other pages.
The File
I have tried the jquery way as well.
The File
<script>
$("#FileDownload").click(function(){
location.reload();
});
</script>
But all the them are not working. Do you masters have any good ideas about this, many thanks.
P.S. What if I wanna add a countdown after a file is being started download, and then do page reload when countdown finishes.
Looks like have asked several questions... Thanks a ton in advance.
This works:
http://jsbin.com/imikit/5
The timeout must be set to more than the response time of the server serving the file, otherwise the javascript won't fire. So set it to something high.
The File
$('#download').click(function() {
setTimeout(function() {
window.location = 'http://www.google.com/';
}, 1000);
});
Or
The File
$('#download').click(function() {
window.location = 'http://www.google.com/';
});
Most browsers will close the newly opened window once the download has initiated.
Lighttpd 2's mod_upload might be worth looking at. Unfortunately there's no stable version of Lighttpd 2 yet.
You could try sending a cookie along with the download, then detecting it with javascript. This will either be set after the headers are sent, or after the body is sent. (test it)
One thing you can do is open the download in a new window, then redirect the page.
The File
<script>
$("#FileDownload").click(function(e){
e.preventDefault();
window.open(this.href);
location.reload();
});
</script>
You have two options for the onClick parameter:
Add semicolons between each line that can have one
Write a function to do all your tasks an have the onClick method call that.
Someone else might be able to help with the jQuery side, but it would be similar, I would think.
All of these methods will fire as many events as you like.
For the countdown, try the setTimeout() function.
EDIT: After seeing comments, try Click Here. This will open the link in a popup window and reload the current one - you may need the setTimeout() for the reload so the link opens before the reload() event fires.
When you click on a link the default action is to follow it and adding onClick code doesn't change that.
Try:
onClick="windows.location.reload();return false;"
This will solve the first part.
As for the second part (counter/redirect on download finish) use this plugin http://johnculviner.com/post/2012/03/22/Ajax-like-feature-rich-file-downloads-with-jQuery-File-Download.aspx to download the file and use successCallback to redirect:
$.fileDownload('/file.pdf', {
successCallback: function () {
windows.location.reload();
}
});
I have a photo gallery that use modal window to display photos. During modal windows initialisation I'm inserting rest of photo functionality (share button, comment, tags, etc). Everything works well except facebook share button. From documentation you have to include following html code:
<a name="fb_share">share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript"></script>
It works perfectly for static pages, but not with the pages that created on the fly.
Here is example of my javascript code (using jQuery)
//Insert share button
$.gallery.facebookLike.insertAfter($('#cboxContent #cboxLoadedContent'));
//Insert script element after share button
$('<script />', {
src : 'http://static.ak.fbcdn.net/connect.php/js/FB.Share',
type: 'text/javascript'
}).insertAfter($.gallery.facebookLike);
As result button inserted but script element is not initialised, after inspection in firebug this script appears in loaded script tab but not present on HTML tab. However if you click on the share link it sends you to facebook page and when you click BACK button in your browser the script gets initialised.
What am I doing wrong and what can be done about it?
I'm just taking a guess here, but I believe the script has a function running on window onload event. Since the window is already loaded, the script isn't running.
Edit: Yes, it seems that the function FB.Share.stopScan is being run on window load. You should try manually calling that function.