Solved

iframe in asp

Posted on 2015-02-11
3
216 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

757 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

21 Experts available now in Live!

Get 1:1 Help Now