Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA VBscript and JavaScript Popup showModalDialog

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
Hi Guys,

This one is a tough one to place as my code uses VBscript and JavaScript, but as the problem is with the JavaScript page, I have optted for this forum. (Granted, it may be the VBScript that is causing the issue).

I have an HTA that calls a Popup using VBScript and showModalDialog. The Popup has only JavaScript that shows a folder tree. Clicking on the folder items, expands the item to the next sub-level. If I open this page stand-alone (from windows explorer) the Popup behaves as it should, however, opening the Popup from the parent window, the tree does not expand. Instead I get a new page opening up with the contents of the href tag showing in the address bar.

I have tried to calling the popup using VBS and JS, both with the same result.

The VBScript code calling the javascript PopUp:
Code:
ShowModalDialog("ouPage.hta")

The JavaScript code calling the JavaScript PopUp:
Code:
[blue]//In parent window[/blue]
<script language="JavaScript">
	function openOUPage() {
	   window.showModalDialog("pages/ouPage.hta"); 
	} 
	</script>

The code for the JavaScript child page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2007 Transitional//EN" > 
<html>
<head>
<meta NAME="GENERATOR" Content="SAPIEN Technologies, Inc. PrimalScript 2007">

<title>Select the Organisational Unit</title>
<HTA:APPLICATION 
     	ID="objUserCreation" 
    	 APPLICATIONNAME="UserCreation"
    	 SCROLL="no"
    	 NAVIGABLE="yes"
		 SINGLEINSTANCE="yes"
   		 WINDOWSTATE="normal"
   		 ICON="..\images\icons\people16x16.ico"
    	 VERSION="1.0.0.0"
     	 SYSMENU="yes"
    	 SHOWINTASKBAR="yes"
	>    
    <!--<LINK REL="StyleSheet" TYPE="text/css" HREF="..\skins\tree.css" />-->
    <link rel='stylesheet' href='..\skins\tree.css'>
    <!--<SCRIPT src="bin\main.vbs" language="VBScript"></script>-->
    <!--<SCRIPT src="..\bin\start.vbs" language="VBScript"></script>
    <SCRIPT src="..\bin\ouSelect.vbs" language="VBScript"></script>
    <SCRIPT src="..\bin\main.vbs" language="VBScript"></script>-->

<script type="text/javascript">
	function Toggle(item) {
	   obj=document.getElementById(item);
	   visible=(obj.style.display!="none")
	   key=document.getElementById("x" + item);
	   if (visible) {
	     obj.style.display="none";
	     key.innerHTML="<img src='../images/tree/folder.gif' width='16' height='13' hspace='2' vspace='1' border='0'>";
	   } else {
	      obj.style.display="block";
	      key.innerHTML="<img src='../images/tree/textfolder.gif' width='16' height='13' hspace='2' vspace='1' border='0'>";
	   }
	}

	function test(){
		alert("hello");
	}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
Select an organisational unit
	<Table height="114" border="0" cellpadding="0" cellspacing="0">
	  	<tr>
	  		<td width='100' height="112">&nbsp;</td>
		</tr>
	</table>
<table border=0 cellpadding='10' cellspacing=0>
	<tr>
		<td>
			<table cellpadding='0' cellspacing=0>
				<tr>
					<td width='16'>
						<a id="xmgmt" href="javascript:Toggle('mgmt');">
							<img src='../images/tree/folder.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
						</a>
					</td>
					<td>
						<a href="javascript:Toggle('mgmt');">Top Level</a>
			</table>
			<div id="mgmt" style="display: none; margin-left: 1.5em;">
		
			
			<table cellpadding='0' cellspacing=0>
				<td width='16'>
					<a id="xappsvr" href="javascript:Toggle('appsvr');">
						<img src='../images/tree/folder.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
					</a>
				</td>
				<td>
					<a href="javascript:Toggle('appsvr');"> App Server </a>
				</td>
				</tr>
			</table>
			<div id="appsvr" style="display: none; margin-left: 1.5em;">

				<table cellpadding='0' cellspacing=0>
					<td width='16'>
						<img src='../images/tree/text.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
					</td>
					<td>
						<a href="../../pages/CareFirst/sm.htm" target="IF1">
							Services
						</a>
					</td>
					</tr>
				</table>




<table border=0 cellpadding='0' cellspacing=0>
	<tr>
	<td width='16'>
	<a id="xexit" href="javascript:Toggle('exit');" target='_self'>
	<img src='../images/tree/folder.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
	</a>
	</td>
	<td>
	<a href="javascript:Toggle('exit');"> Exit</a>
	</table>
	<div id="exit" style="display: none; margin-left: 1.5em;">
	
		<table border=0 cellpadding='0' cellspacing=0>
		<tr>
		<td width='16'>
		<img src='../images/tree/text.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
		</td>
		<td>
		<a href="">
		Switch User
		</a>
		</td>
		</tr>
		</table>
		
		<table border=0 cellpadding='0' cellspacing=0>
		<tr>
		<td width='16'>
		<img src='../images/tree/text.gif' width='16' height='13' hspace='2' vspace='1' border='0'>
		</td>
		<td>
		<a href=vbscript:exitBtn()>
		Close
		</a>
		</td>
		</tr>
		</table>
<!--End Exit-->

</div>
<!--end Expand all - Collapse All-->
<p><a href="javascript:Expand();">Expand All - </a><a href="javascript:Collapse();">Collapse All</a>

</td></tr></table>


</body
</html>


I am wondering if this is a limitation or whether I have done something wrong.

If anyone would be able to shed light on the problem, I would be very grateful.

Many thanks

Woter
 
Code:
[s]<a href="javascript:Toggle('mgmt');">[/s]
<a href="#" onclick="Toggle('mgmt');return false;">
 
Many thanks AvarPentel. Worked a treat. I guess it was because the original worked at it was in a different frame rather than a modal window.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top