Solved

iframe in asp

Posted on 2015-02-11
3
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Make the most of your online learning experience.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse 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…
Suggested Courses

628 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