Classic ASP/Javascript issue in IE11

I am maintaining an old, old classic ASP site - there is a form which includes the following tag around the "submit" image:

<a href="javascript:ValidateMakeForm();" onMouseOver="msover(1); return true" onMouseOut="msout(1)">

The function is defined on the page like below - basically sets the form action and submits the form.

<script language="javascript">
function ValidateMakeForm()
{
	if (document.forms['searchmake'].category_id.selectedIndex == 0)
	{	
		alert("You must select a make.");
		document.forms['searchmake'].category_id.focus();
		return;
	}
	document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
	document.forms['searchmake'].submit();
}
</script>

Open in new window


IE 11 is throwing an error 'ValidateMakeForm' is undefined.   Everything works in Chrome, Firefox and Edge and even in IE 11 when viewed in Compatibility Mode.
ccleebeltPresidentAsked:
Who is Participating?
 
Julian HansenCommented:
Works fine for me.
My sample http://www.marcorpsa.com/ee/t3202.html

You have not really provided us with enough code to replicate the problem I have had to fill in some gaps but it seems to be fine so I am missing something.
0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
Sample codes I tried:
Code 1
29099944.html:
<HTML>
	<HEAD>
		<TITLE>
			29099944
		</TITLE>
		<!--
		29099944.js working
		<SCRIPT src="29099944.js" type="text/javascript">
		</SCRIPT>
		 -->
	</HEAD>
	<BODY style='margin-top:0;margin-left:0;margin-right:0;'>
		<!--
		29099944.js working
		<SCRIPT src="29099944.js" type="text/javascript">
		</SCRIPT>
		 -->
		<FORM name="searchmake" action="29099944.html">
			<!--
			29099944.js working
			<SCRIPT src="29099944.js" type="text/javascript">
			</SCRIPT>
			 -->
			<TABLE border='1' width="100%" height="100%">
				<!--
				29099944.js working
				<SCRIPT src="29099944.js" type="text/javascript">
				</SCRIPT>
				 -->
				<TR>
					<TD valign="top" align="left">
						<SELECT id="category_id">
							<OPTION>
								Select
							</OPTION>
							<OPTION>
								29099944.html
							</OPTION>
						</SELECT>
					</TD>
					<TD valign="top" align="left">
						<!--
						29099944.js working
						 -->
						<SCRIPT src="29099944.js" type="text/javascript">
						</SCRIPT>
						<A href="javascript:ValidateMakeForm();" onMouseOver="msover(1);return true" onMouseOut="msout(1)">
							Validate make form
						</A>
					</TD>
				</TR>
				<TR>
					<TD valign="top" align="right" colspan="2">
							<INPUT type="submit" value="Submit">
					</TD>
				</TR>
			</TABLE>
		</FORM>
	</BODY>
</HTML>

Open in new window

29099944.js:
function msover()
{
}
function msout()
{
}
category_id=document.getElementById("category_id");
function ValidateMakeForm()
{
	if (document.forms['searchmake'].category_id.selectedIndex == 0)
	{
		alert("You must select a make.");
		document.forms['searchmake'].category_id.focus();
		return;
	}
	document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
	document.forms['searchmake'].submit();
}

Open in new window


Code 2
29099944_Code2.html
<HTML>
	<HEAD>
		<TITLE>
			29099944 Code2
		</TITLE>
		<!--
		working
		<SCRIPT type="text/javascript">
			function msover()
			{
			}
			function msout()
			{
			}
			category_id=document.getElementById("category_id");
			function ValidateMakeForm()
			{
				if (document.forms['searchmake'].category_id.selectedIndex == 0)
				{
					alert("You must select a make.");
					document.forms['searchmake'].category_id.focus();
					return;
				}
				document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
				document.forms['searchmake'].submit();
			}
		</SCRIPT>
		 -->
	</HEAD>
	<BODY style='margin-top:0;margin-left:0;margin-right:0;'>
		<!--
		working
		<SCRIPT type="text/javascript">
			function msover()
			{
			}
			function msout()
			{
			}
			category_id=document.getElementById("category_id");
			function ValidateMakeForm()
			{
				if (document.forms['searchmake'].category_id.selectedIndex == 0)
				{
					alert("You must select a make.");
					document.forms['searchmake'].category_id.focus();
					return;
				}
				document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
				document.forms['searchmake'].submit();
			}
		</SCRIPT>
		 -->
		<FORM name="searchmake" action="29099944.html">
			<!--
			working
			<SCRIPT type="text/javascript">
				function msover()
				{
				}
				function msout()
				{
				}
				category_id=document.getElementById("category_id");
				function ValidateMakeForm()
				{
					if (document.forms['searchmake'].category_id.selectedIndex == 0)
					{
						alert("You must select a make.");
						document.forms['searchmake'].category_id.focus();
						return;
					}
					document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
					document.forms['searchmake'].submit();
				}
			</SCRIPT>
			 -->
			<TABLE border='1' width="100%" height="100%">
				<!--
				working
				<SCRIPT type="text/javascript">
					function msover()
					{
					}
					function msout()
					{
					}
					category_id=document.getElementById("category_id");
					function ValidateMakeForm()
					{
						if (document.forms['searchmake'].category_id.selectedIndex == 0)
						{
							alert("You must select a make.");
							document.forms['searchmake'].category_id.focus();
							return;
						}
						document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
						document.forms['searchmake'].submit();
					}
				</SCRIPT>
				 -->
				<TR>
					<TD valign="top" align="left">
						<SELECT id="category_id">
							<OPTION>
								Select
							</OPTION>
							<OPTION>
								29099944.html
							</OPTION>
						</SELECT>
					</TD>
					<TD valign="top" align="left">
						<!--
						working
						 -->
						<SCRIPT type="text/javascript">
							function msover()
							{
							}
							function msout()
							{
							}
							category_id=document.getElementById("category_id");
							function ValidateMakeForm()
							{
								if (document.forms['searchmake'].category_id.selectedIndex == 0)
								{
									alert("You must select a make.");
									document.forms['searchmake'].category_id.focus();
									return;
								}
								document.forms['searchmake'].action = document.forms['searchmake'].category_id.value;
								document.forms['searchmake'].submit();
							}
						</SCRIPT>
						<A href="javascript:ValidateMakeForm();" onMouseOver="msover(1);return true" onMouseOut="msout(1)">
							Validate make form
						</A>
					</TD>
				</TR>
				<TR>
					<TD valign="top" align="right" colspan="2">
							<INPUT type="submit" value="Submit">
					</TD>
				</TR>
			</TABLE>
		</FORM>
	</BODY>
</HTML>

Open in new window

0
 
ccleebeltPresidentAuthor Commented:
So the piece that is not working is on www.gtcovers.com - the Choose Make dropdown at the top of the page.  It is working in Chrome, Firefox, Edge and IE11 in compatibility mode - but not in IE11 when not in compatibility mode.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Julian HansenCommented:
That link does not do anything on FF or Chrome - if I select something - no alert, nothing happens.

There are errors in the console though when the page loads.
The page is loading this script
view-source:https://www.gtcovers.com/le-mtagconfig.js
But the .js file starts with <script> which is not valid in a .js file.
<script> is for use inside HTML documents.
0
 
ccleebeltPresidentAuthor Commented:
The liveperson tag (le-mtaconfig.js) has been removed - after choosing a make in the dropdown you must click the "select  make and continue" button.
0
 
Julian HansenCommented:
The only thing I can see is that your link (button) has a onMouseOver and onMouseOut function
<a href="javascript:ValidateMakeForm();" onMouseOver="msover(1); return true" onMouseOut="msout(1)"><img src="/images/global/button-go_off.gif" width="150" height="20" border="0" name="roll1"></a>

Open in new window

Not sure why the styling of the button is being done with those functions instead of CSS - but try removing those and try again.
i.e
<a href="javascript:ValidateMakeForm();"><img src="/images/global/button-go_off.gif" width="150" height="20" border="0" name="roll1"></a>

Open in new window

0
 
ccleebeltPresidentAuthor Commented:
Yeah - I did try removing those - just swaps the image from orange to blue on mouseover - old way of doing it.
0
 
Julian HansenCommented:
When I remove them - the code works as expected in both IE and FF / Chrome.
0
 
ccleebeltPresidentAuthor Commented:
They have been removed from the site - still getting 'ValidateMakeForm' is undefined when attempting to click the "Select Make and Continue" button after selecting a vehicle make in IE 11.
0
 
Julian HansenCommented:
Change the <script> tag from
<script language="javascript" type="f83c09e7d2bc9dc5fffffba3-">

Open in new window

To
<script>

Open in new window

0
 
Murugesan NagarajanSubject-matter expert at C++ C delivery, implementation, at UNIX oriented operating systems (Windows: CYGWIN_NT MINGW32_NT MINGW64_NT)Commented:
Yes, based on comment from
>> Julian Hansen
replace all such occurrence (to prevent such kind of exceptions):
language="javascript" was used by old browser versions.
a)
Replace:
<script language="JavaScript" src="/common/js/global.js" type="80d3f88428288f35ee2aed52-"></script>
With:
<script src="/common/js/global.js" type="text/javascript"></script>
b)
Replace:
<script type="80d3f88428288f35ee2aed52-text/javascript">
With:
<script type="text/javascript">
c)
Replace:
<script type="80d3f88428288f35ee2aed52-">
With:
<script type="text/javascript">
d)
Replace:
<script language="javascript" type="80d3f88428288f35ee2aed52-">
With:
<script language="javascript" type="text/javascript">
e)
Replace:
<script type="80d3f88428288f35ee2aed52-">
With:
<script type="text/javascript">
f)
Replace:
<script type="80d3f88428288f35ee2aed52-">
With:
<script type="text/javascript">
g)
Replace:
<script type="80d3f88428288f35ee2aed52-text/javascript">
With:
<script type="text/javascript">
h)
Replace:
<script type="80d3f88428288f35ee2aed52-text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
With:
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">

Open in new window

0
All Courses

From novice to tech pro — start learning today.