It's particularly difficult to try to debug an error when you don't state what the error is.
However, I can make a few generalized comments about your code.
Let's start by breaking the page down to it's core elements. You want a javascript function to kick off to send out an email via outlook. Sometimes IE7 will block events that are automatically fired when a page loads (via the onload handler), so we can test for both instances:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script type="text/javascript">
window.onload = blah;
function blah() {
self.location = "mailto:a@b.com?subject=test&body=test";
}
</script>
<style type="text/css"></style>
</head>
<body>
<input type="button" value="click me" onclick="blah()" />
</body>
</html>
In IE7 this worked fine for me. Outlook opens a new mail message when I first load the page, and also when I click the button. So, we know that the issue is that your code is not getting blocked by an onload handler.
Looking at your code I can point out a few things:
Code:
[purple]<script>[/purple]
function initialize()
{
[green]document.forms['form'].elements['email'].value[/green] = temp ;
}
</script>
<script type=[COLOR=pink]text/javascript[/color]>
function openoutlook()
{
var S=[red]document.form.customer.value;[/red]
var B=[red]document.form.comments2.value;[/red]
var M=[red]document.form.email.value;[/red]
var A= [blue]<% = request.querystring("id") %>[/blue]
var url = '[URL unfurl="true"]http://myweb/view1.asp?id='[/URL] + escape(A);
self.location="mailto:abc@mysite.com?subject=An Update Has Been Made To abc Project # "+A+" By "+M+"&body="+M+" Updated Project # "+A+" . Here is the link to the project "+url;
}
</script>
1) In the purple <script> tag you have not specified the type attribute, however you do it in the second <script> tag.
2) When specifying the pink value for the type attribute in the 2nd script tag, you did not encapsulate the value in quotes.
3) You correctly use the forms and elements collections (noted in green) in the first <script> tag, but then you abandon that practice in the second <script> tag (noted in red)
4) You pull the id value directly from the querystring and throw it to the page (noted in blue) with no regard for what type of data may exist there. This would not be that big of a problem except for the fact that you are not encapsulating that value in quotes - forcing it to become a string. If there is a numeric value in the querystring the javascript compiler will have no problem parsing the statement. However, if any non-numeric characters exist then it will crash. You may not structure your page to ever have a non-numeric value in the querystring, but since you're pulling the data from the querystring it means that any user can manipulate that value directly from their browser address bar.
5) And another thing you've added since I started typing this reply is that the the function is triggered from a submit button. Submit buttons are used to submit form data to a specified page. If you're just wanting to trigger this function then you shouldn't be using an input of type "submit" - you should use an input of type "button".
6) yet another thing that you've added since I started typing this reply - you named your submit button "submit". This is extremely bad practice since there is a method already called submit. Using your non-standard code from above where you did not use the forms and element collections, what if you constructed a line of code like this:
Code:
var a = document.form.submit
Are you referencing the submit button, or the submit method? The javascript compiler won't know and it's sure not going to make a guess at what it thinks you mean.
You show a lot of good practice in some of your code above, but then in other spots.... not so much. You should try to be more consistent when writing your code. You will run into many less errors that way.
-kaht
Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P>
<.</B>[/small]