Im having issues with .js codes. the window.open seems to be not working. i have tried using window.location and not working also. Can anyone suggest what could be the fix for this?
Here's the code that im currently using
if ("web page" == $scope.model.ComponentModel.Screen.trnscntype) {
var staffId = ichrisCache.get("loginStaffNumber");
if ($scope.model.ComponentModel.FormCode == 'SEL') {
var menulinkParameters = { staffId: staffId, formCode: $scope.model.ComponentModel.FormCode };
$scope.retLink = "";
var menuLinks = SelfServiceLinkURL.query(menulinkParameters,
function (output) {
$scope.retLink = output;
console.log($scope.retLink);
alert('inside menulinks');
});
alert('outside menulinks');
window.location.href = $scope.retLink;
//window.open("http://www.stackoverflow.com/");
}
else
{
window.open($scope.model.ComponentModel.Screen.urlwebpage);
}
}
although the $scope.retLink can be logged on console.log but when i placed it inside the window.open($scope.retLink); it is not triggering.
Suggestions and inputs are greatly appreciated.
Thanks!
Related
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 have a code that was answered for me in another post which is below. However I have since ran into a new problem that I can't solve easily. I added additional LoadKML functions e.g. Function LoadKML1(), function LoadKML2(). The problem is now I need to click the killKML button to clear LoadKML1 before I can click LoadKML2. I would like to have the LoadKML1 clicked to load the KML and if clicked again LoadKML1 to run the killKML code. basically an on and off button in essence.
Any help is appreciated.
var kmlLoaded = false;
function LoadKML() {
alert('Kill KML');
if (kmlLoaded) {
return
killKML();
}else{
alert('Creating KML');
var nwlink = "http://kml-samples.googlecode.com/svn/trunk/kml/NetworkLink/placemark.kml"
createNetworkLink(nwlink);
kmlLoaded=true;
}
}
function killKML(source) {
ge.getGlobe().getFeatures().removeChild(networkLink);
you could change your code and call the killKML() in the kmlLoaded check like this:
function LoadKML() {
if (kmlLoaded) {
//return
killKML();
}else{
var newlink = "http://www.something.com/test.kml";
createNetworkLink(newlink);
kmlLoaded=true;
}
}
i saw in a website defining script type tag like this , please can anybody tel me what is that "type="text/javascript+fk-window-onload-executed">, what is this "+fk-window-onload-executed" mean?? and why they are using such type..
when i execute below code, code is not executing but when i remove +fk-window-onload-executed then its working fine
<script type="text/javascript+fk-window-onload-executed"">
(function () {
try {
var Lastclick = true;
var viz = document.createElement('script');
viz.type = 'text/javascript';
viz.async = true;
viz.src = ("https:" == document.location.protocol ?"https://" : "http://localhost")+ "/projects2/857/VIZVRM857.src.js";
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(viz, s);
viz.onload = function () {
try {
pixel.parse(Lastclick)
} catch (i) {}
};
viz.onreadystatechange = function () {
if (viz.readyState == 'complete' || viz.readyState == 'loaded') {
try {
pixel.parse(Lastclick)
} catch (i) {}
}
}
} catch (i) {}
})();</script>
please anybody tell me, why they are using such type definition and what is the benefit of using such type.
Thanks in advance..
Please help
From looking at the source you provided this is a custom document type flip kart is using (fk == Flip Kart). My guess would be they are using it to prevent reloading the script on certain occasions.
may someone of you can help me to find this problem?
I've got an xpage with client-side js-code included which should be executed when you decide to leave the page. In the client-side js you refer to a button and click it automatically. This button got some server-side js code included and change the flag from a document from ("opened by ..." to "").
The thing is that somehow the client-side js did not work in all different browsers except the current IE (10.0.5) and throws the error:
unable to load http://urlofthedocument/... status:0
The funny thing about this is, when I insert an alert()-method right after the click()-method everything works fine in every browser. But as I don't want to include this alert statement I figure out there must be something different to avoid this. (A short pause instead of the alert-method also did not work.)
My CS JS-Code:
window.onbeforeunload = WarnEditMode;
function WarnEditMode(){
if(needUnloadConfirm == true){
var el = window.document.getElementById("#{id:Hidden4SSJS}");
el.click();
//document.open();
//document.write(el);
//document.close();
//alert("You're about to leave the page");
//pause(5000);
}
}
function pause(millis){
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis)
}
This refers to to button, which executes following SS JS code, after it is clicked:
try{
print("Hidden4SSJS-Button-Test # Person");
var db:NotesDatabase = database;
var agt:NotesAgent;
var doc:NotesDocument = XPPersonDoc.getDocument()
agt = db.getAgent("(XPUnlockDocument)");
agt.run(doc.getNoteID());
}catch(e){
_dump(e);
}
May you guys can help me with this?
I would do this using the XSP object with a hidden computed field (and not your special button)...
Something like this:
function WarnEditMode(){
if(needUnloadConfirm == true){
XSP.partialRefreshGet("#{id:unlockDocCF1}", {
params: {
'$$xspsubmitvalue': 'needToUnlock'
},
onComplete: function () {
alert('You are about to leave this page and the document has been unlocked.');
},
onError : function (e) {
alert('You are about to leave this page and the document has NOT been unlocked.\n' + e);
}
);
}
pause(5000);
}
Then the computed field's javascript would be something like this:
try{
var sval = #Explode(context.getSubmittedValue(), ',');
if (sval == null) return result + " no action.";
if (!"needToUnlock".equals(sval[0])) return result + " no action.";
print("Hidden4SSJS-Button-Test # Person");
var db:NotesDatabase = database;
var agt:NotesAgent;
var doc:NotesDocument = XPPersonDoc.getDocument()
agt = db.getAgent("(XPUnlockDocument)");
agt.run(doc.getNoteID());
return 'document unlocked.';
}catch(e){
_dump(e);
}
here is my code
var url = window.location.href;
if (url.substr(7, 21) === "www.codtelevision.com")
{
//Valid domain
if (url.substr(29) === "")
{
document.getElementById('homeLink').className = "active";
}
else
{
document.getElementById(url.substr(29) + "Link").className = "active";
}
}
When i look in my chrome developer tools, i see this error.
Uncaught TypeError: Cannot set property 'className' of null
I have tried so many times to fix it but can not. How do i get this to work?
Also, when i just put this in the console, it works:
document.getElementById('homeLink').className = "active";
My website is www.codtelevision.com
maybe your document is not loaded. put your code inside window.onload .
window.onload = function(){
//code
}
or if you are using jquery:
$(document).ready(function(){
//code
});