Terry Rogers
asked on
Convert .asp page to .HTML
We currently have a asp file with the following code:-
I have amended the variables for security reasons.
I need to convert this code into a standard HTML file as server side scripting is disabled on our particular web server and we are unable to get it enabled.
My understanding is that this is simple Javascript so it should be possible to integrate this into a standard HTML page?
Any help would be appreciated as my experience with Javascript is minimal.
<%@ LANGUAGE=JSCRIPT %>
<%
// VARS TO CHANGE
var v1 = 12345;
var v2 = 12345678;
var targetFile = "mysecretpage.asp"
// END VARS TO CHANGE
var enterpriseName = targetFile.substr(0,targetFile.lastIndexOf("."));
function pad(num){
return(num<10?"0"+num.toString():num.toString());
}
var now = new Date();
var key = pad(now.getUTCMinutes()) + pad(now.getUTCMonth()) + pad(now.getUTCDate()) + pad(now.getUTCHours());
key = (key * v1) - v2;
%>
<HTML><BODY onload="document.uptodate.submit();">
<form method="POST" action="http://uptodateonline.com/porthole/<%= targetFile %>" name="uptodate">
<input type="hidden" value="<%= enterpriseName %>" name="username">
<input type="hidden" value="<%= key %>" name="key">
<input type="submit" value="UpToDate">
</form>
</BODY></HTML>
I have amended the variables for security reasons.
I need to convert this code into a standard HTML file as server side scripting is disabled on our particular web server and we are unable to get it enabled.
My understanding is that this is simple Javascript so it should be possible to integrate this into a standard HTML page?
Any help would be appreciated as my experience with Javascript is minimal.
There's nothing in that code that's ASP-specific (except for the "mysecretpage.asp" reference, and that's another page). There's no obvious reason you couldn't just rename this from myfile.asp to myfile.html.
ASKER
That's a javascript issue, and I'm afraid I can't be much help there.
I'll see if I can get an admin to update the tags on your question.
I'll see if I can get an admin to update the tags on your question.
The parts of your form where you set the values are specific to ASP, so you'll need to populate that with Javascript instead. You'll also need to ensure that your Javascript code doesn't run until the page is fully loaded (onLoad event or the jQuery document.ready method):
function setup()
{
var v1 = 12345;
var v2 = 12345678;
var targetFile = "mysecretpage.asp"
var enterpriseName = targetFile.substr(0,targetFile.lastIndexOf("."));
var now = new Date();
var key = ((pad(now.getUTCMinutes()) + pad(now.getUTCMonth()) + pad(now.getUTCDate()) + pad(now.getUTCHours())) * v1) - v2;
var myForm = document.forms['uptodate'];
myForm.action = "http://uptodateonline.com/porthole/" + targetFile;
myForm.elements["username"].value = enterpriseName;
myForm.elements["key"].value = key;
}
function pad(n) {
return (n < 10) ? ("0" + n) : n;
}
ASKER
Hi Chris,
Thank you for your comment.
My knowledge of HTML and Javascript is limited.
How would I fit that javascript code into a HTML page?
Regards
Thank you for your comment.
My knowledge of HTML and Javascript is limited.
How would I fit that javascript code into a HTML page?
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bear in mind that there is absolutely zero security in doing this. It's very easy to see the source of your page, and therefore the mechanics used to generate the key. Don't know if that's a problem for you but thought it worth mentioning
ASKER
Thank you! Works a treat! :)