I have used popup at many places in my website (its in PHP with Mysql DB and lots of javascript). These are mostly been blocked my browsers, which restricts user to move ahead. what should do in my code so that my popups becomes Popyp blocker independent..
Use Jquery Dialogs http://jqueryui.com/demos/dialog/ they are purely javascript and so popup blockers will not block this
Make sure your popups's URL is on the same domain as the main site. Using a link with 'target="_blank"' will never get blocked unless it was manually blocked as the user did the action himself. Switch to alerts and prompts instead of popups.
Not a direct answer but may be Floating div is a good replacement. Build a js dialog box.
Related
is there a way to press a button on external site with javascript and/or jquery? Like I open a new window like this:
windowObjectReference = window.open("http://some_site.html","name");
Then I want to press a button on this site. Something like this:
windowObjectReference.button.click();
Or:
name.button.click();
It would be a huge security violation if a browser would let you do that from the script placed on your own website.
So, no, this cannot be done, and should not be possible.
But...
If both sites belong to you (you have access to their code), you can pass a parameter (eg. as a hash within URL), then the target website may read it and fire the event you mentioned (name.button.click()).
You can't do this with JavaScript from a webpage.
You can do it from browser extension though.
NO !
For security reasons. This kind of attack is called clickjacking! and it was used on Twitter.
is there a way to press a button on external site with javascript
and/or jquery?
I know that I'm late at party but YES, Unfortunately it is and is a quite simple way.
make a div on your page (ex. #externalDiv);
set CSS attribute to hidden and display to none;
use (simple way) jQuery method .load() or make your own JS method using XMLHttpRequest();
load external page on your page;
click on button you wish
$('#externalDiv').load('http://www.externalPage.com', function(){$('#externalPageButtonId').click();});
Can not doge by something if you don't know how it's work :)
You are not allowed to do so because of SOP. Any trick to force user to perform click on your behalf will be considered as clickjacking attack and could lead to bad consequences.
In page one : Form and submit to page two
page two : Insert data, open new tab and redirect to page one
I'm using
window.open("pdf_order.php?p=<?=$paper;?>","_blank");
window.location = "page1.php";
but, It's doesn't work because block popup on browser.
According to your question, you want to issue a window.open call when you arrive on "page two."
You can't, because that's what scuzzy websites used to do, and this is the whole point of popup blockers. Instead, you'll need to adjust the clickflow so you're not trying to do that.
This is a question of the type: Doing X is not allowed. How to do X?
If a popup blocker allowed you to do a popup, it would be a very bad
blocker, and people would not use it.
Please understand that a popup blocker is always a step ahead of you: it uses interface to a concrete Web browser which in turn take a total control of all rendering and scripting on the client side. And your application is supposed to work with all kinds of HTTP client software and be somewhat abstracted from it. From this point, it's easy to understand that it's much easier for a blocker to block your code then break this blocking.
found this answer on http://www.codeproject.com/Questions/474314/PopUpplusBlockerplusisplusdisplayingpluswhenplusop
try AJAX
I'm using a bookmarklet that lets me share the current URL on Google Plus.
Here's the JavaScript:
javascript:(function(){var w=480;var h=380;var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
window.open('https://plusone.google.com/_/+1/confirm?hl=en&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars=no');})();
Is there a way to detect the "Sharing Successful" event and call a window.close()? And where do I call it in this JS? Even a pointer in this direction will be appreciated.
Is there a way to detect the "Sharing Successful" event and call a window.close()?
No you can't.
Browser security prevents you from using Javascript on one page to interact with another page on a different domain. This is why I can't put up a website that opens your bank's website in an iframe and then controls it.
The Javascript in a bookmarklet is considered to be part of the page that is open when you execute it. So the code becomes part of the page you are adding to Google Plus, and it can not interact with the page from Google because it is on a different domain; and vice versa. The code can open the window, but that is all.
To do what you want would require creating an add-on, extension, or user script.
I want to have a popup div with iframe content.
Can search engines read this when I'm using jquery to create it?
Alternatively, is there a way to detect a search engine on the server side and remove the option of this popup?
The best way would be to degrade gracefully, e.g. by using a standard
<a id='mylink' href='xyz.html'>
link that points to the resource that is opened in the popup.
You would then add the JQuery code to the link, causing it to open in the pop-up.
That way, even users that do not have JavaScript turned on can access your popup.
Most Lightbox clones like Thickbox work that way.
Generally speaking, search engines do not execute JavaScript, so there's no way for them to index anything contained in a popup div.
You can, however, inspect User-Agent header to see if the page is requested by web spider, but this is something that's not considered best practice.
Search engines do not play well with javascript but you can see how google bot would fetch your page using Google's webmaster tools.
Rendering a different page to bots is not considered a best practice too. The best you can do is graceful degradation.
Just to say it at once: DON'T use the iframe, as it is bad-ass technology and search engines won't index the iframe'd page.
First question:
No, it cannot, if the data are loaded simultaneously with the popup "popping up" (as search engines, as said already, generally doesn't execute javascript). If the data are already loaded, and the popup div are somehow hidden at page load, the search engine will index the content.
Second question:
Don't do that. That's called cloaking, and will be punished by search engines if detected - they don't like content customized just for them, and then you're back at scratch.
Is there anyway to create an alert box, but with a more modern style? When an alert box is issued, the user can not use the browser until it is acknowledged (enter key or click OK). I would like to lock the browser in the same fashion, however use a custom made, better looking alert box. Is this possible with javascript?
Thanks
Edit: To clarify, by lock the browser I mean unable to change url, open new tab etc. The user needs to confirm before they can switch to another page
Yes. The kind of dialog you're referring to is a modal dialog. The basic principle of implementation is to simply cover the rest of the elements on the page with another element to render them unclickable.
Simply googling "javascript modal dialog" reveals a wealth of information; I could not hope to provide a comprehensive explanation in this small space.
[edited -Nickolay] Such dialog won't block further JavaScript execution as alert() does though, and it won't prevent the user from accessing the rest of the browser (other tabs and the Location bar). It's a good thing the user can continue to use the browser and it's one of the reasons such page-modal dialogs were created.
Yes, they are called "modal dialogs". JQuery has an excellent dialog widget that can be made modal as part of its JQueryUI library that can host just about any type of content, including forms.
See this one
Dialog
using jQuery
or
jQuery Alert Dialogs (Alert, Confirm, & Prompt Replacements)
Edit
To your edit: I don't think by using javascript you can prevent the user from typing it to the url bar or opening a new tab. And do avoid doing these sort of things that make a user hinder his normal action.
No, I don't think modal dialogs solves his question.(Not that I have a solution for this, but just to express my opinion). When you use modal dialogs, the only controls you can't access are those inside the web page but the controls of the browser can very well be accessed (ie. Menus, address bar);
This is not possible in javascript. You may use facebox-like containers, that simulates modal behavior, but there are not native modal, i.e. javascript code will not stop execution, when "modal window" is appear.