View Full Version : Asp Script from htm page onLoad()

03-01-2006, 08:49 PM
I have a software program that genrates .htm webpages. It will not allow me to change extension to .asp It creates e.g. 1000 pages named 1.htm,2.htm ... 1000.htm. The "Title" of each page is the word not number. e.g. <title>One</title>. etc.

The software allows me to add includes and scripts in javascript for the header section. Nothing server side. I can not modify the <body> tag.

I would like to send a CDONTS email when the page loads. I understand cdonts and have a Notice.asp page that sends the type of mail I want.

I would like to add something like an OnLoad() Function (Not on Body Tag) that would say submit a form to action page Notice.asp then return to the .htm page.

Say a surfer opens 1.htm the onload script in the header would submit to Notice.asp Notice.asp would send email then redirect to 1.htm. Seamlessly hopefully. Mailto: in javascript is not my preferred answer.

I tried the onload submit form and in notice.asp I caputured the url of the referrer (1.htm) in a session variable and then redirected to that to get back.

Is this the right approach, and how can I avoid getting into a loop on the return to 1.htm???

Any suggestions or leads certainly appreciated. :confused:


03-02-2006, 10:02 AM
window.onload = function(){
var mail = new Image();
mail.src = "Notice.asp?d=" + Date.parse(new Date()); //the date parameter is to enable the browser not to process the page from cache
That will send request to the server on the background.

03-02-2006, 03:09 PM
You could also use Ajax to call/run the script in the background

The example here is to include a HTML file into a DIV, but if you just have an email script then you can include it into a hidden element.

03-02-2006, 03:57 PM
Oh man! You made my day on this tip! Thank you. Next time you are in the Dallas area, a Cool Bud is on my tab!

Thank you!