This is my scenario. If the session is expired in our system/application it is redirecting to the log-in page.
If i open the application on two different browsers,If session is timed out in one of the broswer window,it must close the other window too.In my case ,i can still process the 2nd browser/window(i can click buttons and etc.,).
Please suggest me what i can do here
<pre>
<code>
This is my java script code:
<script type="text/javascript">
<!--
function closeWindow() {
self.close();
}
// -->
</script>
This is my server side code
If Not clsUserSession.IsSessionExist(getUserid, False) Then
Me.ClientScript.RegisterStartupScript(Me.GetType(), "CloseWindowScript", "closeWindow();", True)
Exit Sub
End If
This is my java script code:
<script type="text/javascript">
<!--
function closeWindow() {
self.close();
}
// -->
</script>
Hope thses will help you
Try with www3school
Window close function api
Related
What I want to do
Get a form using an external script. Prefill and disable some fields. Example:
How I do it
I retrieve a form using an external script(s) :
<!-- Lumesse js imports -->
<!--Apply-->
<script type="text/javascript"
src="https://emea3.recruitmentplatform.com/apply-app/static/apply/release/2-LATEST/apply-preloader-namespaced.js"
th:src="#{https://emea3.recruitmentplatform.com/apply-app/static/apply/release/2-LATEST/apply-preloader-namespaced.js}"
data-lumesse-apply=""
data-lumesse-apply-config-key="XXX"
data-lumesse-apply-host="https://emea3.recruitmentplatform.com"
data-lumesse-apply-description-placement="bottom"
data-lumesse-apply-menu="top"
data-lumesse-apply-menu-placement="top"
data-lumesse-apply-repeatable-style="on-demand">
</script>
<script src="https://emea3.recruitmentplatform.com/apply-
app/static/apply/release/2-LATEST/apply-application-form-namespaced.js"
th:src="#{https://emea3.recruitmentplatform.com/apply-
app/static/apply/release/2-LATEST/apply-application-form-namespaced.js}">
</script>
<!-- in comment because otherwise conflict with static/vendor/jquery.min.js -->
<!-- <script src="https://code.jquery.com/jquery-1.12.3.min.js"
th:src="#{https://code.jquery.com/jquery-1.12.3.min.js}"
th:integrity="sha"
th:crossorigin="anonymous"></script>-->
<script src="https://emea3.recruitmentplatform.com/apply-
app/static/themes/release/latest/silk/js/main.js"
th:src="#{https://emea3.recruitmentplatform.com/apply-
app/static/themes/release/latest/silk/js/main.js}"></script>
The code for prefill or disable works fine.:
<!-- custom javascript -->
<script type="text/javascript" th:inline="javascript" >
$(document).ready(function() {
// fix menu when passed
$('.masthead').visibility({
once : false,
onBottomPassed : function() {
$('.fixed.menu').transition('fade in');
$('.navbar-fixed-top').css({'top': '52px'});
},
onBottomPassedReverse : function() {
$('.fixed.menu').transition('fade out');
$('.navbar-fixed-top').css({'top': '75px'});
}
});
// create sidebar and attach to menu open
$('.ui.sidebar').sidebar('attach events', '.toc.item');
window.setTimeout(function(){
preFillForm();
},0);
});
function preFillForm(){
var gegevens = [[${gegevens}]];
for(var id in gegevens){
$("#" + id).val(gegevens[id]);
}
$("#first_name_1").attr('disabled','disabled');
$("#last_name_2").attr('disabled','disabled');
$("#e-mail_address_3").attr('disabled','disabled');
}
</script>
The problem
My fields don't get prefilled .. My guess is because they don't get reloaded or get overwritten ..
First possible solution
After many hours I added a setTimeout of 0. This seems to work. Now I discovered that this only works on a page refresh or when the user already visited the site and did a page refresh before ...
So still when a user go to the site for the first time it doesn't work ..
Any help would be much appreciated
Cheers
(PS: setTimeout of more seconds is not the way I want to go ..)
UPDATED
My application is a Spring Boot App. Working with Thymeleaf. Also use of Semantic and Jquery in FrontEnd.
Try using sessionStorage or localStorage (sessionStorage seems to be better in this situation).
https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
How do u greayout backbutton or view source of browser so users can't click backbutton and view source code because javascript contains lot of business logic code. I need to greayout those options so users can't be able to click them. i recently joined banking project and i am beginner in java and development.
Try adding this in the Head section of your html file:
<script type="text/javascript">
window.history.forward();
function noGoingBack() {
window.history.forward();
}
</script>
And add this in your Body section:
<body onload="noGoingBack();" onpageshow="if (event.persisted) noBack();" onunload="">
This prevents the page from going back.
I have a Blogger Blog, and I want to setup a link that auto open when someone visit me. I found some scripts that works on this site.
But I don't know how to stop the script when its function is done. Any suggestion? I'm totally a noob with this language.
This is the script what I have choose:
<script language="javascript" type="text/javascript">
<!--
window.setTimeout('window.location="example.blogspot.com"; ',2000);
// -->
document.AddEventListener("DOMContentLoaded","CallThis");
function CallThis(){
window.location="www.blah.com";
}
Please elaborate,
Do you want to redirect the user to a different page or do you want to redirect him to the same page and that puts you in a loop ?
If you want to redirect a user to a different page the second the page loads use the following command :
<script language="javascript" type="text/javascript">
window.onload = function() {
window.location.replace("http://someplaceamazing.com");
}
</script>
if you want to redirect a user to the same page (reload the page) but not reload it everytime, just a single time use this :
<script language="javascript" type="text/javascript">
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload();
}
}
</script>
I bought this program that created a pretty nice imageuploader flash script however I can't get the Javascript function close window to close the popup and redirect the original page.
here is the XML piece that defines the url's:
<urls urlToUpload="upload.php?" urlOnUploadSuccess="http://www.home.com/purchase.html"
urlOnUploadFail="http://www.home.com/tryagain.html"
urlUpdateFlashPlayer="http://www.home.com/flashalternative.html"
jsFunctionNameOnUpload=""/>
This last line calls a javascript function on upload. The problem is I don't know what to call and where to put it.
Here is the HTML file that is the popup:
<HEAD>
<title>Baublet Uploader</title>
<script type="text/javascript" src="swfobject.js"></script>
</HEAD>
<BODY>
<!-- Q-ImageUploader www.quadroland.com -->
<div id="QImageUploader">
Flash Player stuff here
</div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("q_image_uploader.swf", "imageuploader", "650", "430", "9", "#FFFFFF");
so.addParam("scale", "noscale");
so.addParam("salign", "TL");
so.addVariable("AdditionalStringVariable","pass additional data here");
so.write("QImageUploader");
// ]]>
</script>
I found this Closing script I thought might work:
<script language="javascript">
function close_window(page) {
window.opener.location.href=page
setTimeout(function(){window.close()},10);
}
</script>
Does this go into the Popup HTML page above or would it be a separate close.js file in the root?
Thanks,
I'm really confused.
It looks like that bit of script belongs to the popup. It changes the parent window's location and then closes itself after a ~10ms delay. The function close_window most likely is being called by the Flash applet.
Reqs:
I want to make an external page with a 'Become a Fan'-button.
I want users to login to facebook once they open the page (this is because of other features in the site)
So I call FB.Connect.requireSession once the page loads, and put a <fb:fan></fb:fan> control on the page.
Then when I open the page I see the 'Connect with Facebook to Continue' pop-up and a small 'Become a fan' button. This seems right. When I log in to Facebook using the pop-up the 'Become a fan button' disappears!!
Can anyone explain this weird behaviour or does someone know a way to reach my requirements in a different way.
Below you can see my code.
Thanks in advance!
<!-- Head -->
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/nl_NL" type="text/javascript"></script>
<script type="text/javascript">
var fbApiKey = "MY_KEY";
var fbXdReceiver = "xd_receiver.htm";
function fbLoad() {
FB.init(fbApiKey, fbXdReceiver);
FB.ensureInit(function() {
FB.Connect.requireSession(null, null, false);
});
}
</script>
<!-- Body onload="fbLoad();" -->
<fb:fan profile_id="24932281961" name="Nutella" id="fanButton" stream="0" connections="0" logobar="0" width="250"></fb:fan>
I solved this by making the page refresh after a successful login
So I call requireSession with a callback
FB.ensureInit(function() {
FB.Connect.requireSession(requireSessionSuccess, null, false);
});
And this is the code for the callback
function requireSessionSuccess() {
window.open('default.aspx?fbloggedin=true', '_self');
}