By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,714 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,714 IT Pros & Developers. It's quick & easy.

Insert a file name in the src part of an iframe statement

P: 3
Here is the javascript I have written and part of the XHTML but it doesn't work.
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--function CalcMonth() -->
  3. {
  4. var mydate=new Date();
  5. var month=mydate.getMonth();
  6. var montharray=new Array('janstats.html','febstats.html','mar','apr','may','jun','jul','aug','sep','oct',"novstats.html",'dec');
  7. var fyyle="";
  8. fyyle=(montharray[month]);
  9. document.write(fyyle);
  10. }
  11. </script>
  12. </head>
  13. <body>
  14. <p><iframe src="'fyyle'" style="width:840px; height:1000px; border:none; margin-left:365px;"></iframe></p>
  15. </div> -->
  16. </body>
  17. </html>
  18.  
  19.  
Nov 7 '11 #1
Share this Question
Share on Google+
4 Replies


Dormilich
Expert Mod 5K+
P: 8,639
a) itís not XHTML (you would see an XHTML error)
b) <!--* is not valid JavaScript syntax


* - HTML commenting JavaScript code was required back in the old days of IE 3, where browsers would treat JS code as text. nowadays, no browser will do that mistake.
Nov 7 '11 #2

P: 3
Thanks for your response. However, what I need to know is how to place the filename selected at line 8 into the iframe statement at line 14. Please help
Nov 12 '11 #3

Dormilich
Expert Mod 5K+
P: 8,639
something along
Expand|Select|Wrap|Line Numbers
  1. document.write('<iframe src="' + CalcMonth() + '"></iframe>');
Nov 12 '11 #4

P: 3
Thanks to Dormilich. Your 2nd answer allowed me to get my problem sorted out. It now works fine.

Griffo42
Nov 14 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.