I saw this post: pop-up div over parent window and the message about yensdesign, which is fine, but it still doesn't "quite" cover what i would want, which is:
At this moment I have two popups. One for when the window closes and the other pops up when the visitor has been on the page for x seconds. Downfall of this is:
1. It's [fill in]-ugly
2. One of them looks like a div, the other like a popup (in firefox), while they look like very simple and ugly popups in other browsers.
So I would like to have the same function, but then with divs, so that they will look nicer and behave appropriately amongst all browsers.
The only stuff I can find has code for closing divs... so could someone help me out please?
Edit: See http://www.cornerstws.com/test.html for the simple javascript solution that I had so far.. (popup appears after 3 sec and the other popup appears when you close the window (or refresh.. not nice either)).
as i understood from ur question that you want a popup that can be triggered through java script function
u can check this blog for a simple popup
http://blog.theonlytutorials.com/a-very-simple-jquery-popup-ready-to-use-code/
and then u can restyle it to meet ur needs and u can use this function
$('#pop').click();
rather than clicking the link to open the popup.
hope this answer helped you
Related
I have request from the customer to adjust some old functionality in the system. The current file has href links that look like this:
#Name#
If you look the code above you see that target="_blank" page will be opened in the new browser window. However, user wants to be able to close that window if they click OK/Cancel button in page.detail.cfm. I tried using this code for closing the browser window:
var closeBtn = document.getElementById('btn_cancel');
closeBtn.addEventListener('click', cancel);
function cancel(){
window.close();
}
After I tested the code and clicked Cancel message in the dev tools looks like this:
Scripts may not close windows that were not opened by script.
I guess that window can't be closed if not previously opened with JavaScript. I'm not sure what would be the best approach to solve this issue? Thanks for your help.
Technically a script is not allowed to close a page that a user has opened as opposed to it being opened by a script itself. It's a browser security issue. I know there were some hacks for it but thing like this get patched pretty quick from what I can tell. You could technically open the window with a script instead with some sort of click event or such, but again this is a bit of a work around. Check this out https://developer.mozilla.org/en-US/docs/Web/API/Window/close
I have actually created a modal pop-up which pops up when someone clicks on an element on my website.
However it always pops up at the top of the page / bottom of the page (where I have inserted the code.) Fixed, also isn't a good solution, as if the modal is long, it cannot be readed.
I basically want it to pop up for example 50px lower than the current window, so it will always pops up to the user, he/she doesn't have to scroll down/up.
Is there any plugin to solve this solution, in jQuery?
Google search for: 'jQuery modal popup' gave me this http://dinbror.dk/bpopup/ – looks exactly like what you need.
I am trying to have a dynamic popup window in an html page. the popup will appear when the user hovers a word. and in the popup window i want to call a webpage with the hovered word as parameter. It does not need to work on every word in the page. Only hover on the words i select will work like that.
For example i have a text "hello this is a sample text" in my html page and the user hovers the mouse on the word "sample" a popup will appear and in the popup i will show the following page "www.blabla.com/?word=sample"
hope i was clear.
I want it to be able to work on a static page. I am very new to javascript. I am not even sure where to start so any help would be appreciated.
Thanks.
edit: i want the popup to be a modal popup.
That is very basic, read tutorials on http://www.tizag.com/javascriptT/javascriptevents.php and http://www.w3schools.com/jsref/met_win_open.asp
But I can tell you, that with this sort of method, browsers will trigger their pop up blocker.
Get the elements you want to have this effect, loop over them, add event listeners to each of them which pops a window up.
This is a crude implementation of something like this, where the words have the class popup around them:
[].slice.apply(document.getElementsByClassName('popup')).forEach(function (elem){
elem.addEventListener('mouseover', function (){
window.open('http://google.com/?q=' + this.innerHTML);
}, false);
});
Demo
I am using window.open() method to open a page as a pop-up window for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons. How can remove these buttons?
This is the method i am using,
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
Tell me how can do this.
Regards,
Chirag Jain.
You can't.
If you want a popup style window without full window decorations you'd have to create a new overlay <div> on top of the existing content and fill that with content, perhaps using an <iframe>.
You can't do it from javascript alone. Think about it, if you could, then people could put it into code on web-pages and cause other people's computers to open windows they couldn't easily close.
Instead you'll have to look for an answer specific to whichever browser you're using to host this application, and change it on the computers of your users appropriately. Even then though I don't think you'll be in luck (with Firefox for example, I can see how to get rid of them on all browser windows, but not on just one).
Hy guys,
i made a upload page, after the sucess of operation i would like to close the html page automatically or by a link or something.
window.close don't work in this case, 'cause is not a window pop up.
Any ideas?
Best regards,
Valter Henrique.
There is no way to do this and that's a good thing. It may confuse the user. Instead, show a message telling the user that they may close the window now.
I see you want to close the greybox from within the child page. Try
top.GB_hide();
If window.close() won't work, you can't do anything else.
Which is good, because I don't want sites closing my window.
You could try window.close(), and then immediately after it update the DOM with a message such as "This window may be closed." That way, if you ever can close the window (perhaps some browsers may let you), you will cover both bases.
some kind of hack here...but may not work in all browsers
window.opener=null;
window.open('','_self');
window.close();