do command + var containing Javascript

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

do command + var containing Javascript

Post by cborn » Mon Aug 23, 2010 7:39 pm

Is it possible to compose a dynamic Javascript command and then load the variable into the 'do' command to execute?

I'm loading a revlet into a dynamic lesson page in a course management system. The revlet is collecting params from the page and I would like to use them to test for a create a new URL to go to when the revlet submission is complete. I've tried a number of different iterations of this and none of them seem to execute in the browser. Am I missing something or is there another way to do this?

Code: Select all

   put (tCurrentPageURL & "&pageid=" & tParams["pageid"]) into tNewPageURL
   put (quote & "window.location.href='" & tNewPageURL & "'" & quote) into tGoToNewPage
   do tGoToNewPage in browser
I've also tried:

Code: Select all

   put (tCurrentPageURL & "&pageid=" & tParams["pageid"]) into tNewPageURL
   put (quote & "window.location.href='" & tNewPageURL & "'" & quote) into tGoToNewPage
   put tGoToNewPage into field "Statements"
   do field "Statements" in browser
I have done a bunch of testing and I know that the tGoToNewPage is loading well-formed Javascript, but it is not executing. :(
I would appreciate any advice!!

carly

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: do command + var containing Javascript

Post by Mark » Mon Aug 23, 2010 10:34 pm

Hi Carly,

Which version of RunRev are you using?
Try this:
put ("window.location.href='" & tNewPageURL & "'") into tGoToNewPage
Does your Javascript syntax work as part of an html file?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: do command + var containing Javascript

Post by cborn » Mon Aug 23, 2010 10:38 pm

Hi Mark,

I think I've tried that one already, too.

Yes, if we manually run that JS from an HTML file, it does work. I'm just not sure if I can use variables as the statementlist of the 'do' command.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: do command + var containing Javascript

Post by Mark » Tue Aug 24, 2010 10:58 am

Version?
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: do command + var containing Javascript

Post by cborn » Tue Aug 24, 2010 1:53 pm

sorry, Rev Enterprise version 4.0.0, build 950

cborn
Posts: 66
Joined: Fri Dec 15, 2006 11:35 pm

Re: do command + var containing Javascript

Post by cborn » Tue Aug 24, 2010 3:31 pm

In testing it out again this morning, it seems to behave as desired. I had thought I tried all iterations of the JS statement, but perhaps I missed the one that worked! :oops:

Thanks for the suggestion, Mark!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: do command + var containing Javascript

Post by Mark » Tue Aug 24, 2010 5:38 pm

I'm glad to know it works, cborn. Another reason why it didn't work before but did work now might be that you didn't have the latest version of the plug-in installer before. Just make sure to always have the latest version.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply