w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How can I show alert in parent window from child popup window in javascript?
try this code <!DOCTYPE html> <html> <head> <script> function openWin() { myWindow=window.open('','','width=200,height=100'); myWindow.document.write("<p>This is 'myWindow'</p>"); refreshParent(); } function refreshParent() { window.parent.focus(); window.parent.alert("message"); window.parent.location.reload(); } </script> </head> <body> <input type="button" value="Open 'myWindow'" onclick="openWin()" /> </body> </html>

Categories : Javascript

javascript: Accessing parent object from event listener in draw method of jcanvas
On entering your Board constructor, assign this to a local variable (self) so other functions defined in the same scope can have access to it. Something like the following will work: var Board = function($element){ var self = this; this.place_piece = function(piece){ this.board[piece.position[0]][piece.position[1]] = piece; $element.drawImage({ source: piece.image, draggable: true, layer: true, x: this.get_coordinates_by_cell(piece.position)[0], y: this.get_coordinates_by_cell(piece.position)[1], dragstop: function(layer){ console.log(self) console.log($this) console.log(layer) } }); }

Categories : Javascript

Replace Page Links on Popup Page With Javascript to Open in Main (Parent) Window
You cant replace attribute target, from attribute href. use el.target and just set the value var aEls = document.getElementsByTagName('a'); for (var i = 0, aEl; aEl = aEls[i]; i++) { aEl.target="_parent"; }

Categories : Javascript

Disable parent window when child popup window is open
Play around with this code in the pop-up: $(window).on("blur", function(){ ... }); This will fire every time the user leaves the window. Inside the argument function you should be able to make the window regain its focus, maybe using $(this).focus() or self.focus(). I haven't tested this myself. Good luck!

Categories : Javascript

Popup Window with javascript - open new popup in the old popup window
Don't you just want to close the old window each time #canvas is clicked? //earlier: var winPop = false; // in the click event: if (winPop) { winPop.close(); } winPop = window.open('About.aspx?info=' + info, "pop", "resizable,width=1000,height=600,"); And to close it later: window.onbeforeunload = function(e) { if (winPop) { winPop.close(); } };

Categories : Javascript

Detect event from iframe works with jQuery event listener on parent, but now with pure JS
Here, your event is triggered on body, so you should listen for events on body, not document : document.querySelector("body").addEventListener("myevent:load",function() { console.log("Hello"); },false); Syntax : https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener

Categories : Javascript

Greasemonkey popup loop not waiting for load-event listener
See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener. The second argument of the addEventLister function must be a pointer to a function and not a call.

Categories : Javascript

Is There Any Way We Can Get Url Of PopUp Windows In Parent Window
You can call a function onclick and have the url there as a variable: <a href="#" onclick="my_function()">Click Here</a> And then you can do anything you want with the url: function my_function() { var url = 'http://www.google.com'; window.open(url ,'MyWindow',width=600,height=300); //show the url in an element return false; }

Categories : Javascript

Value from a popup window in a parent element
You can access the element's text through text(). You can change the value of the field through using val() That would make your code something like this $(function(){ $('.newsPicture').click(function() { window.close(); //get the text of the element we clicked var pictureName = $(this).text(); //put this value in our field $('#newsPicture').val(pictureName); }); }); or a shorter solution would be $(function(){ $('.newsPicture').click(function() { window.close(); $('#newsPicture').val($(this).text()); }); });

Categories : Jquery

Disable parent window of popup in JSP
You can use JQuery UI Dialog, and set it as modal form. Read this SO answer for more tips. Another option would be iterate through all the input and anchor in the page and and explicitly set disabled=true for each of them. This blog describes how to disable all page elements with transparent div , using CSS and bit of javascript.

Categories : Java

open the link from the popup window in an external window and then close the original popup window
Try <input name="Apply Online" type="button" id="Apply Online" value="Apply Online" ONCLICK="window.location.href='some_url';$.colorbox.close();"> or <input name="Apply Online" type="button" id="Apply Online" value="Apply Online" ONCLICK="window.location.href='some_url';parent.$.colorbox.close();">

Categories : Javascript

How to reload parent page on closing PopUp window?
You can access parent window using 'window.opener', so, write something like the following in the child window: onunload="window.opener.location.reload();" or use this <script> window.onunload = refreshParent; function refreshParent() { var retVal = confirm("Are you sure ?"); if( retVal == true ){ window.opener.location.reload(); else return false; } </script>

Categories : C#

add Event Listener to button Titanium, link to window
Do like this playButton.addEventListener('click' , function() { var w = Titanium.UI.createWindow({ url:'playWindow.js' }); w.open() }); Thanks

Categories : Javascript

Java Swing second window calls event listener twice after being disposed
@LiverpoolFTW: Please provide a SSCCE demonstrating the problem. Absent sufficient code, I speculate you're (re-)adding the MouseListener/MouseAdapter each time your window is opened. The following example works as desired as-is, incrementing the clickCount once per button press or label double-click. But if you uncomment the indicated section, you'll see that the doClick() is executed twice when you double-click the label. If you have, for example, some component to which you're adding a listener each time the window opens, each of those listeners will be executed. package example.stackoverflow; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.BoxLayout; import javax.swin

Categories : Java

Jquery popup pass selected checkbox values to Parent window not working
You're not actually creating a real window. It's an overlay. So it's not a popup, it's not a window, and thus there is no window.parent for what you're working in. Instead you have a hidden div / form that gets shown and positioned overtop of your window. Since this is all done with CSS and Javascript, there is no parent to your form because it's in the same window as the rest of your markup. I'm sure if you looked at the javascript console of your browser you'd see an error along the lines of window.parent is null / not an object. There's the explanation. Here's the answer: remove window.parent and parent from your code. And since it's not a window, you're not closing a window, so your close is likely a fadeOut. $(document).ready(function(){ $('#overlay_form').submit(function

Categories : Javascript

2 button OnClick event on Popup Window in Android
try this import android.os.Bundle; import android.app.Activity; import android.app.Dialog; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button bt_1 = (Button) findViewById(R.id.bt1); bt_1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub final Dialog dialog = new Dialog(MainActivity.this); dialog.setContentView(R.layout.activity_popup); dialog.setTitle("Hans Kelsen");

Categories : Android

Datagrid bound list not being updated visually from Popup Window event wpf
Without more information, I would guess that it is indeed a focus issue. Try using a standard MessageBox instead. It should keep your focus a lot tighter than a window and allow your code to execute entirely within DeleteEverything(). You can use the MessageBoxResult to determine whether or not to actually delete everything inside DeleteEverything() after MessageBox.Show("blahblahblah") has returned.

Categories : Wpf

Call JavaScript of parent window from child window
What you're looking for is a reference to the window that opened the popup window. Once you have that, you can call functions in that window, read and write variables in that window, or even manipulate its DOM. That reference is called opener. It gives you the window object for the window that opened the current window. For example, if you have a function in the original window like this: function updateMe( data ) { alert( data ); } then in the popup window you could call it like this: opener.updateMe( 'Hello!' ); Naturally, you need to make sure that updateMe() is a global function in the original page. Or if you have some object in the original page and updateMe() is a method of that object, you can still do it, as long as the object is global. e.g. in the host page: var myOb

Categories : Javascript

multiple event listener in javascript
Try this: function addMultipleEvents(elements, events){ var tokens = events.split(" "); if(tokens.length == elements.length){ for(var i = 0; i< tokens.length; i++){ elements[i].addEventListener(tokens[i], (e.which == 13 || e.which == 48)?myFunc:); //not myFunc() } } } var textObj = document.getElementById("textId"); var btnObj = document.getElementById("btnId"); addMultipleEvents([textObj,btnObj], 'click keyup'); UPDATE: function addMultipleEvents(elements, events) { var tokens = events.split(" "); if (tokens.length == elements.length) { for (var i = 0; i < tokens.length; i++) { elements[i].addEventListener(tokens[i], myFunc); //not myFunc() } } } var textObj = do

Categories : Javascript

Getting this from javascript event listener in backbone.js
you need to use _.bind() to pass a custom context to the callback document.addEventListener('touchstart', _.bind(this.touchstart, this)); document.addEventListener('touchmove', _.bind(this.touchmove, this));

Categories : Javascript

Forcing Event Listener in JavaScript
Check out this answer You can use fireEvent on IE, and w3c's dispatchEvent on most other browsers. To create the event you want to fire, you can use either createEvent or createEventObject depending on the browser.

Categories : Javascript

How to attach an event listener to a javascript var
AFAIK there are no way to add a event listener to the plain object, as it is not placed inside DOM. Events are firing inside DOM, and bubbling so your event listener for custom object won't receive it. There is a http://www.bobjs.com/ framework that can help you implement custom events.

Categories : Javascript

Returning a value from popup window using php and javascript
Do you really want encodeURIComponent(pid) here? Try without encodeURIComponent: window.open('search_project.php?id=pid','popuppage', 'width=400,toolbar=1,resizable=1,scrollbars=yes,height=400,top=100,left=100');

Categories : PHP

Handling popup window with javascript
Try this: <button onclick="myFunction()">Add Link</button> <p id="demo"></p> <script> function myFunction() { var url = prompt("Please Enter the Link"); window.location = url; } </script> http://jsfiddle.net/douglasloyo/rtghQ/ the only value that is acceptable in js fiddle is going to be http://jsfiddle.net/ Cheers

Categories : Javascript

How to close a popup window using Javascript
You are not opening any window, You are trying to show Div as pop up box so Add a button to close This button should be added inside the pop up box <input type="button" value="close" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style. display='none'" >

Categories : Javascript

How to define an Event Listener if the Event Listener class is in a namespace
You need to ensure that your namespace is actually being loaded. Aka, somewhere in your composer.json file - are you telling composer/laravel where this namespace resides? If not, that's your first step. You usually need to add it to the psr-0 location, like so: "autoload": { "psr-0": { "MyApp": "src/" } } This tells laravel/composer that your code for the namespace "MyApp" is found at src/MyApp (with your Events folder being a logical extension of that).

Categories : PHP

How to get child window url from parent window using javascript
You can't detect the event precisely, but you can do a workaround and check the URL all X milliseconds. var self = this var detectsUrl = setInterval(function(){ var a = winRef.document.createElement('a'); a.href = winRef.document.URL; if (a.hostname == "www.myURL.com") { winRef.close(); clearInterval(detectsUrl); self.callback(); }; }, 1000); // Here we check every seconds

Categories : Javascript

PLease tell me how to auto click in popup window by using Id of popup window page
You were almost there. Just use variable created when window is opened. var aut=window.open('https://www.mysite.com/mypage'); aut.document.getElementById('ID in abovepage').click(); // this will locate and click element within "aut" window. Note: This will work only if parent and popup belong to the same domain.

Categories : Javascript

How to close a popup window when a button on the popup window is click?
In the parent window I placed a function called close_Popup(). function closePopup() { $.window.closeAll(); } And in the popup window I used also the codes below to call the function in the parent window to close the popup window. $("#no").click(function() { top.closePopup(); }); the "top" javascript function is used to call the function "closePopup()" that resides in the parent window and it solves the problem.

Categories : Misc

Javascript How to tell if event.preventDefault has occurred on a listener
You can achive your goal using object identity. Quote from MDN: Multiple identical event listeners If multiple identical EventListeners are registered on the same EventTarget with the same parameters, the duplicate instances are discarded. They do not cause the EventListener to be called twice, and since the duplicates are discarded, they do not need to be removed manually with the removeEventListener method. Example: // the "one" handler function instance var theEventPreventDefaultHandler = function (event) { event.preventDefault(); }; var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { links[i].addEventListener("click", theEventPreventDefaultHandler); } Watch the Fiddle. I didn't check that out, but it could be possi

Categories : Javascript

How close popup window on ESC keydown on javascript
You can't, but you can use ajax to load specified content into a simulated window (a div or something styled like a window, that should not be hard to do), in your own page, where you can do anything you want. This is also (in most cases anyway) a better way to load content than pop-ups.

Categories : Javascript

Create a popup window in plain javascript
The easiest way is to have a superimposed div with a a high z-index, with transparent background acting as an overlay. You could then have another div which is centered above the overlay(with higher z-index) and containing the list markup CSS #shim { opacity: .75; filter: alpha(opacity=75); -ms-filter: "alpha(opacity=75)"; -khtml-opacity: .75; -moz-opacity: .75; background: #B8B8B8; position: absolute; left: 0px; top: 0px; height: 100%; width: 100%; z-index:990 } #msgbx { position: absolute; left: 50%; top: 50%; height: 150px; width: 350px; margin-top: -75px; margin-left: -175px; background: #fff; border: 1px solid #ccc; box-shadow: 3px 3px 7px #777; -webkit-box-shadow: 3px 3px 7px #777; -moz-border-radius: 22px; -webkit-border-radius: 22px; z-index:999 } HTML <div id="shim">&l

Categories : Javascript

Move a popup window in JavaScript using setInterval
The opened url has to be on the same domain as stated in this answer (DEMO). For example on jsfiddle, this works: var printOut = window.open("http://fiddle.jshell.net","_blank", 'height=200, width=200'); And that one doesn't: var printOut = window.open("http://www.google.com","_blank", 'height=200, width=200'); You should also remove the alert, although it works in chrome it seams to break it in for example opera.

Categories : Javascript

javascript: register a second event listener. How to prevent certain events go to it
I also wouldn't recommend to override the addEventListener method. But I also think that it can't be bad to try certain things out for oneself to test and see if and where there are certain problems. So anyway, here is an idea of how you could do it: var f = Element.prototype.addEventListener; Element.prototype.addEventListener = function(type, func, x){ var that = this; if (that.evts === undefined) { that.evts = {}; } if (that.evts[type] === undefined) { that.evts[type] = []; f.call(that, type, function(){ for (var i = 0; i < that.evts[type].length; i++) { that.evts[type][i].apply(that, arguments); } }, x); } that.evts[type].push(func); }; I'm not a hundred percent confident that I didn't

Categories : Javascript

JavaScript event listener performance for hundreds of DOM elements
The answer is a big whooping YES. Yes, it will affect performance. Event delegation was built for this exact thing. Instead of binding your handler to every single li, bind it to its parent, the ul. This way the ul will delegate the click event to li. $("ul").on("click", "li", function () { //your code });

Categories : Javascript

Javascript Add Event Listener for change in Audio Volume
You're looking for the "volumechange" event. var audio = document.getElementById('sample'); audio.addEventListener('volumechange', function() { console.log('changed.', arguments); }, false); I'm using the bubble phase(as opposed to capture) in this example. http://jsfiddle.net/426E6/ http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#event-definitions

Categories : Javascript

A Javascript event listener's anonymous function keeps returning the same value?
Your guess is correct. The behavior you see is because of your scope. When your link is clicked javascript is passing the current value of a. This value is tab_array.length-2 instead of the value a had during the loop run 0, 1 .... To keep the value of a you have to create a new variable in a new scope (closure). E.g. e: for (a=0; a<=tab_array.length-3; a++) { function(e){ document.getElementById("mini_"+e).addEventListener("click",function(){open_tab(e)},false); }(a)); } Another way would be to write a function which returns your handler inside its own scope: //add events for (a=0; a<=tab_array.length-3; a++) { alert(a); document.getElementById("mini_"+a).addEventListener("click", open_tab(a) ,false); } function open_tab(e) { return function() { //change a

Categories : Javascript

Javascript adding event listener with custom callback?
Your function works. The event is keydown, not keyDown. See demo of your code. Though there can be events with upper case letters, all the usual ones are lower case only. Check here for reference: https://developer.mozilla.org/en-US/docs/Web/Reference/Events

Categories : Javascript

window.opener undefined in javascript popup after redirect
There is a way to achieve what you want, it may not be very clean though. So index.html and result.html are on the same domain and script in index.html contains a reference to window object of a popup. This means that if you set some property on window object in result.html you will be able to read that property on win variable in index.html. The only problem is you don't know when exactly the property is being set, so you will have to use setInterval to check it. Index.html function openPaymentWindow() { var win = window.open('popup.html', 'popup'); var successPoller = setInterval(function() { try { if(typeof win.PAYMENT_SUCESS !== 'undefined' && win.PAYMENT_SUCESS) { document.getElementById('result').style.background = 'green';

Categories : Javascript

How to determine which JavaScript file opens a popup window
Save the web page with the option Web Page, complete (this option is available in most if not all major browsers). This will save all of the HTML, CSS, JavaScript, image and other media files embedded in the page. You may delete the images, media, and even CSS. Start taking out every <script> element one by one, checking each time to see if the button still functions. If it doesn't, put it back and continue with the other elements until you've narrowed it down to the one or few critical elements. Start reducing the JavaScript code in the same way, whether it is in an external JS file or internally written in a <script> block. Take out a variable or function one at a time, checking each time to see if it works. In the end, you will have reduced the code to a minimal test case

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.