Solved

iframe in asp

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select only the top record in a left join 13 37
Math Equation 23 88
Create animated movies for web page 18 45
parse url to form? 6 10
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

810 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