Is there any way we get to know from which page the radwindow got called/opened from?
I have one RadWindow which will be opened by two pages,So if I can know the name of the page I can check on that and execute different Code.
Thanks
absolutely: this is currenlty what I have in my project and its working in production:
here is the Code inside the Child Window
function GetRadWindow() {
var oWindow = null;
if (window.radWindow)
oWindow = window.radWindow;
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
return oWindow;
}
function GetparentWindowname()
{
var _ParentName=GetRadWindow().BrowserWindow.document.location.href;
alert(_ParentName);
}
Regards
Related
This is probably such a noob question, but I can't get it to work.
I want to open external window link by clicking on anchor tag, but I keep getting error that myFunction() is not defined.
Open link
js
$(document).ready(function() {
$('#searchEng').click(function() {
const engine = document.getElementById('engine');
var en_ = engine.val();
if (en_ == "firefox")
{
function myFunction() {
var url = "https://www.mozilla.org/en-US/firefox/new/";
window.open(url,'_blank');
};
}
});
));
Why is it undefined?
I have .js included because other stuff works.
you can remove function inside click function
$(document).ready(function(){
$('#searchEng').click(function() {
const engine = document.getElementById('engine');
var en_ = engine.val();
if (en_ == "firefox")
{
var url = "https://www.mozilla.org/en-US/firefox/new/";
window.open(url,'_blank');
}
});
Open link
You declared myFunction inside another function, which makes it a local variable of that function. Local variables aren't available outside the function where they were defined.
I have integrated 'Embed Layout' comet chat on my site. Now I want to open particular friend chat on page load.
In the documentation, I've found below code to do the same. REF : Documentation Link
jqcc.cometchat.chatWith(user_id)
I have included in custom js from admin panel. However, it is showing below error in console
jqcc.cometchat.chatWith is not a function
But If I use same after friends list loaded from the console it is working fine.
How can I fix this issue?
Currently for time being I have fixed this issue by adding below code in custom js
var first_chat_loaded = false;
var first_chat = setInterval(function () {
try {
if (first_chat_loaded === false) {
// Function to get other user id defined in parent html page
var other_userid = parent.get_other_user_id();
jqcc.cometchat.chatWith(other_userid);
first_chat_loaded = true;
clear_first_load();
}
} catch (e) {
}
}, 1000);
function clear_first_load() {
clearInterval(first_chat);
}
Please let me know, If there is any proper way to do the same.
Kindly make use of this code snippet for the above mentioned issue
var checkfn = setInterval(
function(){
if(typeof jqcc.cometchat.chatWith == 'function'){
jqcc.cometchat.chatWith(user_id);
clearInterval(checkfn);
}
},
500);
I am trying to popup aspx page using window.open in parent page
var win = window.open("apConfirmInvoiceSubmit.aspx");
win.focus();
hWnd =window['rturn'];
if((hWnd == 1) || (hWnd == 2))
{
document.getElementById("ctl00_hdnInvoiceSubmit").value = hWnd;
document.getElementById("ctl00_btnOK").style.display = "none";
document.getElementById("btnattach").style.display = "none";
document.getElementById("txtAref").innerHTML="";
document.getElementById("ctl00_txtWait").style.display = "";
return true;
}
In child page
function SendValue(i)
{
window.opener['rturn'] = i;
window.close();
}
Window.open failed to popup immediately. It popups after executing complete logic and returning undefined for the first time
Would appreciate anyone please help me with this issue.
Please let me know if my explanation is not clear or if more information is required
I'd like to open a new window, this window has a list of objects, and these objects should be filtered based on a selection from the previous window. I figured I can filter the list through a function, but how do I run said function?
This is what I am able to do:
var popup = window.open('pageURL');
$(popup.document).ready(function() {
// this is where function should be
popup.alert('HelloWorld');
});
But how do I change the alert to a function?
If I have a function on my other app , function test() { alert('HelloWorld'};
How do I run this function from my first app?
Swapping popup.alert('HelloWorld'); with popup.test(); did not work.
You need the reference to the window opened to call functions in the new window, like:
var oNewWindow = window.open("new.window.url", "mywindow");
oNewWindow.onload = function(){oNewWindow.window.newWindowFunction();};
I ended up with this solution
var popup = window.open('http://s234-0057/actiontracker/SiteAssets/Avvik/html/app.aspx');
var readyStateCheckInterval = setInterval(function() {
if (popup.document.readyState === "complete") {
clearInterval(readyStateCheckInterval);
popup.test();
}
}, 50);
Where I check if the popup window is ready, and when it is, cancel check and run function. Solution is from top answer on this question, by #this.lau_
You can write it like this:
function myFunction(){
alert('HelloWorld');
}
var popup = window.open('pageURL');
$(popup.document).ready(function() {
popup.eval(myFunction + "");
popup.myFunction();
});
myFunction in file that contains this code will run in page with pageURL address.
I posted a very much similar question yesterday but no one answerd so far. Now I have changed the functionality and stuck with the following problem. In this scenario, I have a RadWindow that i am opening from code behind file (.aspx page) on a button click. On this rad window I have a hidden field where I am setting value and now OnClientBeforeClose event I want to get the value from hidden field and assign it to a text box on my .ASPX page which is the parent page of this Rad Window. Could please anyone give me any idea how to do that. I have looked inot many examples on Telerik and StackOverflow but nothing working for me. Thanks in advance.
Rad Window Diclaration in my .Aspx.cs page
RadWindow window = new RadWindow();
window.Title = "Comments Pick List";
window.ID = "CommentsListPopUpRadWindow";
window.NavigateUrl = "CommentsList.aspx";
window.OnClientBeforeClose = "CommentsListPopUpRadWindowBeforeClose";
window.Skin = "Metro";
window.Behaviors = WindowBehaviors.Close;
window.KeepInScreenBounds = true;
window.VisibleStatusbar = false;
window.Modal = true;
window.Width = 750;
window.MinHeight = 510;
window.VisibleOnPageLoad = true;
window.EnableViewState = false;
RadWindowManager1.Windows.Add(window);
JavaScript function on RadWindow .ASPX page where I am setting value to the hidden field
function displayItem(id) {
var selectedText = document.getElementById(id);
document.getElementById('hiddenSelectedTextField').value = selectedText.innerText;
}
JavaScript OnClientBeforeClose function on my .ASPX parent page (to close the RadWindow) where I am trying to get value from the hidden field and set in the TextBox of parent page
function CommentsListPopUpRadWindowBeforeClose(oWnd, args) {
}
You can easily pass arguments to the RadWindow's Close function, from the child page:
function GetRadWindow() {
if (window.radWindow) {
return window.radWindow;
}
if (window.frameElement && window.frameElement.radWindow) {
return window.frameElement.radWindow;
}
return null;
}
function ChildClose() {
GetRadWindow().Close(document.getElementById('hiddenSelectedTextField').value);
}
and then retrieve the argument in the parent page by specifiying its OnClose function:
Add, in the aspx.cs file:
window.OnClientClose = "CommentsListPopUpRadWindow_OnClose";
and in the aspx parent page:
function CommentsListPopUpRadWindow_OnClose(radWindow, args) {
var arg = args.get_argument();
}