I'm trying to update the shopping cart quantity of the main window from a popup window.
How can I call the shopping cart controller from the popup before closing it and then display the result in main window?
I'm trying to call the spring controller using javascript.
window.opener is a reference back to the opening window. Here's some sample code:
win1.html:
pop up<br/>
set var
<div id="mydiv"></div>
win2.html:
<script>
window.opener.document.getElementById("mydiv").innerHTML = "test";
window.opener.myvar = "test2";
</script>
This is not an answer but more of a pointer. Oliver has given the right answer. If you are willing to experiment with new ways for achieving this you can try cross window messaging available in newer browsers. Here's a link to get you started
http://ejohn.org/blog/cross-window-messaging/
Related
I'm trying to check whether the popup window I want to open is opened or not.
I have checked some question answers like
How would you check if a popup window exists using selenium webdriver?
But, nothings helped to solve the problem.
Here, first I open the login window by clicking the login button.
driver.findElement(By.xpath("//a[#id='login_btn']")).click(); // Click Login Button
I even tried getPageSource() but, it seems not working.
Any kind of help would be appreciated.
Thanks in advance. :)
If it's a native, browser alert (= a popup) you can do the following:
try{
driver.switchTo().alert();
// If it reaches here, it found a popup
} catch(NoALertPresentException e){}
What it looks like you're actually dealing with is an iframe which you can do the following after getting the attribute value of the "iframe" attribute:
driver.switchTo.frame("ValueOfIframe");
// Treat as normal webpage. Now in iframe scope
driver.switchTo.defaultContent(); // To return back to normal page scope
String mwh=driver.getWindowHandle();
Now try to open the popup window by performing some action:
driver.findElement(By.xpath("")).click();
Set s=driver.getWindowHandles(); //this method will gives you the handles of all opened windows
Iterator ite=s.iterator();
while(ite.hasNext())
{
String popupHandle=ite.next().toString();
if(!popupHandle.contains(mwh))
{
driver.switchTo().window(popupHandle);
/**/here you can perform operation in pop-up window**
//After finished your operation in pop-up just select the main window again
driver.switchTo().window(mwh);
}
}
First of all i would like to say that i have gone through all the posts which are similar to my query but i have some different requirement.
In our project we are using gwt to develop the modules, in one of our module, we have "Edit" button which opens a new browser window which includes 'CKEditor'.
We are modifying the data in ckeditor comes(by url) from gwt widget .
The Window opens by using following code snippet(JSNI) in my gwt widget:
private static native BodyElement getBodyElement(String url) /*-{
var win = window.open("url", "win", "width=940,height=400,status=1,resizeable=1,scrollbars=1"); // a window object
return win.document.body;
}-*/;
The newly opened window have the html form which is with ckeditor.
So here i am closing new window once my form has been submitted but i want the edited text to be displayed in old window.
How can i achieve this requirement?
If you can use HTML5, it should be quite easy. Use Messaging.
Take a look here:
Cross-document messaging
With the reference of the newly opened window, yu can establish a communication between both windows.
I got a webengage or clickdesk alert popup but that is intermittent, so I can't check everytime or wait for it to load, everytime I enter a new webpage because that would make my test case run very slow. Is there any workaround for it ( may be blocking it).
For WebEngage, all you got to do is call the respective clear() methods for the products being used on the site (to get rid of the corresponding UI components), as underneath:
webengage.feedback.clear();
webengage.notification.clear();
webengage.survey.clear();
However, this would only work when WebEngage has loaded on the page. If you'd like to completely disable loading of WebEngage products, insert this code in head tag of the page you are testing:
var window._weq = {};
_weq['webengage.defaultRender'] = false;
You can do a lot more cool stuff like the above using our JavaScript API: http://docs.webengage.com/api/js-api-v-4.0.html
Avlesh | CEO, WebEngage
If you are using ClickDesk on your website and would like to delete the Proactive rules which pop up the chat window randomly, then these can be deleted or edited to change the frequency from this link on your ClickDesk Dashboard - https://my.clickdesk.com/#proactive.
In case, you do not want the chat widget to show up at all until clicked on a text link or an image link then, you can add our Custom image link or text link code on your website, this would enable the chat widget only when clicked on it. You can find this link here - https://my.clickdesk.com/#departments/default.
If you have further questions or concerns with regards to ClickDesk, you can visit our website www.clickdesk.com and chat with one of our agents online.
Thanks
Mike Evans
ClickDesk Corporation
My main goal: When i click the link, a new browser window should be opened and displays the content of entire log file. And the window should not have an address bar and navigation buttons (Back, Forward).
Is there any approach to do this in Spring-MVC project?
Here is what i am doing now:
When i click the link, the controller will be called with a parameter logName.
Now the controller have access to get any kind of details of the log file like content, path, etc... I am setting all these details to an object and sending back to JSP.
Here i am not sure how to open a new window and display the content of the log file in that window.
Please suggest me an approach on this!!
It would be very helpful for me if you can share me with some examples...
Spring or JSP have nothing to do with it, the only way to force user's browser to open a link in a new tab is to use client-side Javascript. window.open() allows configuring the popup to hide certain interface elements (see all options in the documentation)
Your code would look something like:
<input type="button" value="Show Log" onclick="showLog(logName)">
function showLog(logName) {
var url = "/path-to-your-controller.html?logName=" + logName;
window.open(url, "LogPage", "toolbar=no,location=no,menubar=no");
}
However, I don't think using a customised browser popup is a good solution; it's been disappearing from the web for a reason. It would be more elegant to fetch raw data using AJAX and display it in a JS popup: it wouldn't interfere with user's page navigation (you tagged the question with jQuery, you could use jQuery UI for that).
What is more, I wouldn't be surprised if window.open wasn't supported by all browsers in the same way† - something to keep in mind if you're targeting a wider audience.
† seems that Chrome ignores location=no, for instance
I have a button which opens a pop-up window and an Ajax update panel. Inside that window I have another button.
What code do I have to run if I want that update panel to be refreshed, when I press the button from the parent page, without refreshing the whole page?
I sow this code on a web which refreshes the page:
<div id="Container" onclick="__doPostBack('UpdatePanel1', '');">
I am such a good friend with Java.
You need to utilize window.opener object.
window.opener.document.getElementById('Container').onclick();
I'd suggest using jQuery to ensure cross-browser compatibility. And also adding some null-checks of course.
Use Jquery :
If the DIV ID remains static :
$("#Container").click(function() {
// REFRESH CONTAINER HERE
});
If the Div ID is dynamic then make use of class instead of ID:
$(".Container").click(function() {
// REFRESH CONTAINER HERE
});