Javascript is broken in revBrowser

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Javascript is broken in revBrowser

Post by EssoAir » Sat Feb 22, 2014 3:48 pm

Hello everyone!

I have an app I'm working on. I have written a bunch of Javascript that works great when run from the Web Console on Firefox, Chrome and Safari. But when I run any of it in revBrowser, the only thing I get to work is "alert('message');"

I'm quite experienced in Javascript and cross-platform compatibility, so it's not my Javascript that's wrong. All I can figure is I didn't setup the revBrowser properly or its a bug in Livecode its self.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Javascript is broken in revBrowser

Post by Klaus » Sat Feb 22, 2014 5:05 pm

Hi Esso,

maybe you can post your relevant scripts and we take a look?
We sure believe that your JS scripts are wonderful, so maybe problem lies in using LC? :D


Best

Klaus

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: Javascript is broken in revBrowser

Post by EssoAir » Sat Feb 22, 2014 7:15 pm

Klaus wrote:Hi Esso,

maybe you can post your relevant scripts and we take a look?
We sure believe that your JS scripts are wonderful, so maybe problem lies in using LC? :D


Best

Klaus
Here is is :3 (except where it says [dot] is obviously "." but i had to change it because the forum wont let me post links. Same goes for [httpColonSlashSlash] = "http" + ":" + "//")

Code: Select all

// ------ Script 1 ------

// window.location = "[httpColonSlashSlash]lnstemac[dot]knoxschools[dot]org/loggedout.phtml";
var jq = document.createElement('script');
jq.src = "[httpColonSlashSlash]code[dot]jquery[dot]com/jquery.min.js";
document.head.appendChild(jq);
$("body").hide();
$("#mainBody > table:nth-child(2) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1)").appendTo("html");
$("#sfLoginForm > table:nth-child(10) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > input:nth-child(1)").removeAttr("value");
$("#saLoginPwField > input:nth-child(1)").removeAttr("value");
var checkForVals = 0;
var usernameLoad = "" + document.cookie + "usernameSave=;";
usernameLoad = usernameLoad.split("usernameSave=")[1];
usernameLoad = usernameLoad.split(";")[0];
if(usernameLoad !== "")
{
	$("#sfLoginForm > table:nth-child(10) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > input:nth-child(1)").val(usernameLoad);
	checkForVals = checkForVals + 1;
}
var passwordLoad = "" + document.cookie + "passwordSave=;";
passwordLoad = passwordLoad.split("passwordSave=")[1];
passwordLoad = passwordLoad.split(";")[0];
if(passwordLoad !== "")
{
	$("#saLoginPwField > input:nth-child(1)").val(passwordLoad);
	checkForVals = checkForVals + 1;
}
if(checkForVals == 2)
{
	$("input#sa_login_btn").click();
}
function saveMe()
{
	if(usernameLoad == "")
	{
		var usernameSave = $("#sfLoginForm > table:nth-child(10) > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(2) > span:nth-child(1) > input:nth-child(1)").val();
		document.cookie="usernameSave=" + usernameSave + "; expires=Fri, 31 Dec 2100 12:00:00 GMT";
	}
	if(passwordLoad == "")
	{
		var passwordSave = $("#saLoginPwField > input:nth-child(1)").val();
		document.cookie="passwordSave=" + passwordSave + "; expires=Fri, 31 Dec 2100 12:00:00 GMT";
	}
}
$("#sa_login_btn").attr("onclick", "saveMe()");

// ------ Script 2 ------

var jq = document.createElement('script');
jq.src = "[httpColonSlashSlash]code[dot]jquery[dot]com/jquery.min.js";
document.head.appendChild(jq);
window.location = $(".wel_grades > a:nth-child(1)").attr("href");

// ------ Script 3 ------

var jq = document.createElement('script');
jq.src = "[httpColonSlashSlash]code[dot]jquery[dot]com/jquery.min.js";
document.head.appendChild(jq);
$("body").hide();
$("#mainBody > div:nth-child(2)").appendTo("html");
$("div").css("width", "100% !important");





Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Javascript is broken in revBrowser

Post by Klaus » Sat Feb 22, 2014 7:31 pm

Well, I actually meant the Livecode script(s) 8)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9842
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Javascript is broken in revBrowser

Post by FourthWorld » Sat Feb 22, 2014 8:25 pm

I believe the DOM window.location has no meaning in the LC browser object, since in that object the browser is fixed within a window managed by another program (LC).

It may be simpler to just use LiveCode to change the location of the LiveCode window:

set the loc of this stack to...
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: Javascript is broken in revBrowser

Post by EssoAir » Sun Feb 23, 2014 2:56 am

FourthWorld wrote:I believe the DOM window.location has no meaning in the LC browser object, since in that object the browser is fixed within a window managed by another program (LC).

It may be simpler to just use LiveCode to change the location of the LiveCode window:

set the loc of this stack to...
Thats a comment in my code. When I get home ill upload the .livecode

The problem is not window navigation. The problem is everything else. Literally the only thing I can get to work is alert() and var NAME = "" But everything else fails to run from what I can tell and on top of that theres no error console like normal web browsers :(

EssoAir
Posts: 52
Joined: Thu Feb 20, 2014 7:53 pm

Re: Javascript is broken in revBrowser

Post by EssoAir » Mon Feb 24, 2014 2:25 am

heres the livecode

[Card 1]

global sBrowserId

on openCard
browserOpen
end openCard

on browserOpen
put the windowid of this stack into tWinID

put revBrowserOpen(tWinID,"[httpColonSlashSlash]lnstemac[dot]knoxschools[dot]org/loggedout.phtml") into sBrowserId

revBrowserSet sBrowserId, "showborder","true"
revBrowserSet sBrowserId, "rect",rect of the me
get revBrowserExecuteScript(sBrowserId, "")
end browserOpen

[/Card 1]

Post Reply

Return to “Talking LiveCode”