Solved

iframe in asp

Posted on 2015-02-11
3
219 Views
Last Modified: 2015-02-11
I have an asp page that is linked using session variables( so  link.com/doc_choose.asp?cat=5). I can display an iframe with no problem using a script such as:

<script type="text/javascript">
						 

if (1 < 1100) 
{
document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}

else
{

document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}
</script>  

Open in new window



I want to show the iframe only on certain pages and not all. How can I get that session variable to work? If I do this:

     
 <%
    gotcat = Request.querystring("cat")
%>

Open in new window


I can not use the gotcat variable  in my script above. Also if I use this code

   
  <%
    gotcat = Request.querystring("cat")
	if gotcat < 6 Then 
	document.Write(<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>)
	end if
%>

Open in new window



Then I get this error:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/doc_choose.asp, line 90

document.Write(<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>)
---------------^


So how can I see the variable that is passed to display an iFrame?


Thanks so much
0
Comment
Question by:Biofilminc
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
Big Monty earned 500 total points
ID: 40604607
iframes, wow! my first recommendation would be to get rid of such an outdated technology! :)

given that's not an option, your problem is you're mixing client side and server side code incorrectly. try this:

<%
    gotcat = Request.querystring("cat")
    if gotcat = "" or not isNumeric( gotcat ) then gotcat = 0
%>
<script type="text/javascript">
						 
var gotcat = <%=gotcat%>;

//-- now you can do your if statement
if( gotcat == 6 ) 
{
document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}

else
{

document.write('<iframe src="announcements.asp" height="200" width="600" marginwidth="0" marginheight="0" frameborder="0"></iframe>'); 
}
</script>  

Open in new window

0
 

Author Comment

by:Biofilminc
ID: 40604616
I have no choice. Its an old intranet. I get what I get sadly.

That solved it. I knew I was mixing languages but didn't know how to make the variable work across both.

var gotcat = <%=gotcat%>;     <<<<< That was what was holding me up.  Thanks so much.
0
 

Author Closing Comment

by:Biofilminc
ID: 40604617
Perfect and easy.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now