GrahamDLovell
asked on
Javascript Code to open a new web page
I am trying out Embarcadero's HTML5 Builder, and want to have a two-screen mobile application. I can write a button which calls a Javascript function.
It is a simple question, but I can't figure out what to put in the (simple) one-line command to open the second screen.
It is a simple question, but I can't figure out what to put in the (simple) one-line command to open the second screen.
<a href="javascript:;" onclick="window.location = 'http://example.com/submit.php?url=' + escape(document.location.h ref);'">Go </a>;
ASKER
This is standard javascript code for an onclick event.
My problem is with the HTML5 Embarcadero IDE, and here I need a call embedded in a function. Sorry that I wasn't clearer.
The example code for a Hello Word app, which refreshes the screen label when you click on MButton, and supply an input name (in the field Edit1), looks like this:
function MButton1Click(event) {
$('#MLabel1').html("Hello, " + $('#MEdit1').val() + "!");
}
Some of this syntax is understandable, eg. ("Hello, " + $('#MEdit1').val() + "!"), but rest is a total mystery. I have never come across this before.
My problem is with the HTML5 Embarcadero IDE, and here I need a call embedded in a function. Sorry that I wasn't clearer.
The example code for a Hello Word app, which refreshes the screen label when you click on MButton, and supply an input name (in the field Edit1), looks like this:
function MButton1Click(event) {
$('#MLabel1').html("Hello,
}
Some of this syntax is understandable, eg. ("Hello, " + $('#MEdit1').val() + "!"), but rest is a total mystery. I have never come across this before.
The rest is JQuery
What it is saying is
$('#MLabel1') gets a reference to the MLable1 element as a JQuery object.
Once you have this you can call the .html method on that object which basically sets the innerHTML of the element so the line basically does this
Set the html content of the element identified by MLabel1 to the string Hello concatenated with the Value of the input element with id MEdit1
In terms of showing the other screen - is this a completely new page or a simulated "new screen" i.e. a hidden div that is then displayed on some event?
What it is saying is
$('#MLabel1') gets a reference to the MLable1 element as a JQuery object.
Once you have this you can call the .html method on that object which basically sets the innerHTML of the element so the line basically does this
Set the html content of the element identified by MLabel1 to the string Hello concatenated with the Value of the input element with id MEdit1
In terms of showing the other screen - is this a completely new page or a simulated "new screen" i.e. a hidden div that is then displayed on some event?
ASKER
Good explanation. Thanks for the direction. I will read up on JQuery.
I was planning that the other screen just be a completely new page that I will pre-prepare.
I was planning that the other screen just be a completely new page that I will pre-prepare.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.