IE 11 Crashes In Windows 10 - javascript

I'm experiencing an issue with a login page. When the page loads the F12 Developer tools gives this error - SCRIPT1002 on FWi.js (1,1). When I put in the login information and submit the tab crashes and reopens. This is the script information from that file.
<script src="../../js/lib/jquery.min.js"></script>
<script type="text/javascript" src="../../js/lib/gibberish-aes-1.0.0.min.js"></script>
<script>
var encrypt = function(uobj, token) {
var str = JSON.stringify(uobj);
var encrypted = GibberishAES.enc(str, token);
return escape(encrypted);
};
$(document).ready(function() {
$("#submitButton").click(function(event) {
event.preventDefault();
var loginForm = document.getElementById("loginform");
var un = $(loginForm).find('#user-name').val(),
up = $(loginForm).find("#user-pass").val(),
tok = $(loginForm).find("#ekey").val();
var encrypted = encrypt({username:un, password: up, instanceType: "browser"}, tok);
$("#user-name").remove();
$("#user-pass").remove();
var encup = $('<input type="hidden" name="authorization" value="Bearer ' + encrypted + '"/>');
$(loginForm).append(encup);
loginForm.submit();
});
});
</script>
Any ideas what could be causing this issue?

Related

Geolocation not working with PWA on iPhone

I have a PWA that uses the Google Maps API and places an avatar on the map in accordance with javascript navigator.geolocation.getCurrentPosition() method.
It all works well when I open the PWA on ANY browser in ANY laptop and Android/iPhone mobile phones, but as soon as I published it in the Play and App Stores, it stopped working on iPhone (but still working on Android). The geolocation doesn’t work at all and doesn’t even ask permission to allow the app to use geolocation. I saw in forums everywhere and there’s a large tendency that says geolocation on installed web apps on iPhone doesn’t work.
First, in a previous PHP page I use the jQuery ajax() method:
echo '
<script>
var idcidade = '.$_POST['hitfcidadeid'].';
$.ajax({
url:"geolocalizacao.php",
method:"POST",
data:{hitfcidadeid: idcidade}, success:function(data)
{}
});
</script>
';
In geolocalizacao.php I save the coordinates to two cookies:
if (isset($_POST['hitfcidadeid']))
{
echo '
<script>
function showLocation(position) {
document.cookie = "geolocationlat = " + position.coords.latitude;
document.cookie = "geolocationlong = " + position.coords.longitude;
}
function errorHandler(err) {
document.cookie = "geolocationlat = '.$linha['CIlat'].'";
document.cookie = "geolocationlong = '.$linha['CIlong'].'";
}
if(navigator.geolocation) {
var options = {timeout:60000};
navigator.geolocation.getCurrentPosition(showLocation, errorHandler, options);
} else {
document.cookie = "geolocationlat = '.$linha['CIlat'].'";
document.cookie = "geolocationlong = '.$linha['CIlong'].'";
}
</script>
';
}
Later on, on my map page:
function getCookie(name)
{
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
if (getCookie("geolocationlat")==null || getCookie("geolocationlong")==null)
{
var lattemp = <?=$cidadelat2?>;
var longtemp = <?=$cidadelong2?>;
}
else
{
var lattemp = parseFloat(getCookie("geolocationlat"));
var longtemp = parseFloat(getCookie("geolocationlong"));
}
Result:
Laptop browser (chrome) – ok;
Android browser (chrome) – ok;
iPhone browser (safari) – ok;
Android web app – ok;
iPhone web app – not ok - returns null
thanks in advance,

How to fix "MasterPage is undefined" in javascript function?

I am currently supporting a web-based app in asp.net vb. This part of code below is for checking the session and automatically logs off the user after the expiration of session. Also, I have a security window that pops up upon the successful log in and also logs off the user whenever this pop up window is refreshed or closed.
The problem is I am having an error saying "MasterPage is Undefined" whenever the javascript is calling the functions in MasterPage.master.vb. The error occurs on code MasterPage.LogOn(), MasterPage.GetClientSession(), and the likes.
Below is my javascript in the MasterPage.master file and the functions LogOn(), GetClientSession() and others are on the MasterPage.master.vb file.
This issue only occurs upon the deployment of the system on the test server, and works fine on my local pc.
Anyone who can help please. Thanks so much.
<script type="text/javascript" language="JavaScript">
var SessionTime = 0;
var uname = "";
var status = "";
var clientSession = 0;
var spyOn;
function logon()
{
MasterPage.LogOn();
clientSession = MasterPage.GetClientSession().value;
spyOn = MasterPage.spyOn().value;
setTimeout("CheckSession()", 60000);
if (!spyOn)
{
var spyWin = open('spy.aspx','UserSecurity','width=250,height=100,left=2000,top=2000,status=0,scrollbar=no,titlebar=no,toolbar=no');
}
}
function CheckSession()
{
SessionTime = SessionTime + 1;
if (SessionTime >= clientSession)
{
var uname = document.getElementById("ctl00_hdnUser").value;
var status = document.getElementById("ctl00_hdnStatus").value;
var x = MasterPage.SessionEnded(uname, status).value;
alert(x);
window.open("Login.aspx","_self");
}
setTimeout("CheckSession()", 60000);
}
function RorC()
{
var top=self.screenTop;
if (top>9000)
{
window.location.href="logout.aspx" ;
}
}
function LogMeOut()
{
window.location.href="logout.aspx" ;
}
function ShowTime()
{
var dt = new Date();
document.getElementById("<%= Textbox1.ClientID %>").value = dt.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000);
MasterPage.CheckSession(CheckSession_CallBack);
}
window.setTimeout("ShowTime()", 1000);
function CheckSession_CallBack(response)
{
var ret = response.value;
if (ret == "")
{
isClose = true;
window.location.href="login.aspx"
}
}
</script>
This can be fixed by adding handlers (<httphandlers> under <system.web> section and <handlers> under <system.webserver> section) on web.config that supports IIS7 and also setting the application pool on IIS manager from "Integrated" to "Classic".

authentication issues from getting a json result

i got a problem with my login script in a platform of creating native mobile app
the server side work perfectly
here is my test with postman
and this is the function that should redirect me to another page bit it don't
function auth() {
var login = js.getProperty('username', 'value');
var password = js.getProperty('password', 'value');
var url = 'http://meanlast.gear.host/user/login';
url = url + '&login=' + login + '&password=' + password;
var response = js.getDataFromUrl(url);
var jsonRep = JSON.parse(response);
if (jsonRep == "Login successful!") {
js.alert("ok");
js.navigateToPage('menu');
} else {
js.alert("error");
}
}
Your code
var url = 'http://meanlast.gear.host/user/login';
url = url + '&login=' + login + '&password=' + password;
produces
"http://meanlast.gear.host/user/login&login=login&password=password"
Do you see the problem with your querystring? You do not have a ?

PhantomJS get JS refresh

I need to check every content change on a web site.
I wrote a PhantomJS function to get the whole web site. After receiving the web site I parse every row to get the data.
Now I want to hold the connection and receive all JS-updates.
What need I do to get the JS-updates?
I hope my question is clear.
Here some code explanations:
Pseudo HTML Website
<html>
<head>...</head>
<body>
<div class="value-123" onload="(function() { setInterval(retrieveData(...), 5000); })">
<!-- If retrieveData finished, VALUE will change from e.g. 1.23 to 4.235 -->
VALUE
</div>
</body>
</html>
My PhantomJS Code:
const string cEndLine = "All output received";
var sb = new StringBuilder();
var p = new PhantomJS();
p.OutputReceived += (sender, e) =>
{
if (e.Data == cEndLine)
{
callBack(sb.ToString());
}
else
{
sb.AppendLine(e.Data);
}
};
p.RunScript(#"
var page = require('webpage').create();
page.settings.loadImages = false;
page.viewportSize = { width: 1920, height: 1080 };
page.onLoadFinished = function(status) {
if (status=='success') {
setTimeout(function() {
console.log(page.content);
console.log('" + cEndLine + #"');
phantom.exit();
}," + waitAfterPageLoad.TotalMilliseconds + #");
}
};
var url = '" + url + #"';
page.open(url);", new string[0]);

window.location.href doesn't work in phonegap app

For some strange reason my Facebook connect does not work in my app in building, after it connect a blank screen it and it dies.
My script works in browser, BlackBerry 10 webworks app, browser on my BlackBerry Z10, Galaxy Tab, Playbook, even on the computer it works fine, but not in the app it self.
I know on BlackBerry 10 you need to disable the app in browser, i tried but did not work.
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
function fboauthstart() {
var url = 'https://graph.facebook.com/oauth/access_token?client_id=' + facebookOptions.clientId + '&redirect_uri=' + facebookOptions.redirectUri + '&client_secret=' + facebookOptions.clientSecret + '&code=' + authCode;
$.ajax({
type: 'GET',
url: url,
success: function(data) {
var response = data;
var response = response.split('&');
var theAccessToken = response[0].split('=');
window.accessToken = theAccessToken[1];
fbfirstlinkcheck();
}
});
}
function startOAuth() {
var url = 'https://www.facebook.com/dialog/oauth?client_id=' + facebookOptions.clientId + '&redirect_uri=' + facebookOptions.redirectUri + '&scope=email,read_friendlists,user_online_presence,publish_stream,user_birthday,user_location';
childWindow = window.open(url, '_blank');
window.int = self.setInterval(function() {
var currentURL = childWindow.window.location.href;
var callbackURL = facebookOptions.redirectUri;
var inCallback = currentURL.indexOf(callbackURL);
if (inCallback == 0) {
window.clearInterval(int)
var code = childWindow.window.location.search;
code = code.split('code=');
code = code[1];
window.authCode = code;
childWindow.close();
setTimeout(function() {
fboauthstart();
}, 1000);
}
}, 1000);
}
I try to replace the href with assign, replace but also not worked and then on the computer it didn't work anymore.
I tried to change window.open to window.location.assign but also that did not work.
Anyone have experience with this?
You need to use this
window.location.replace("link.html");
InAppBrowser plugin "transforms" the javascript window.open function. It will not return a Window object any more but a InAppWindow.
You can still poll the children window, but by executing remote script:
var win = window.open( "http://...." );
win.addEventListener( "loadstop", function() {
var loop = setInterval(function() {
win.executeScript(
{
code: "window.myData"
},
function( values ) {
alert(values[0]);
}
);
});
});

Categories

Resources