473,472 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Function expected" error in random movie/video script

3 New Member
I've been fighting this problem all day but can't seem to get it to work no matter what I try. I would think it would be very simple, but...

rdmMovie.js
=========

Expand|Select|Wrap|Line Numbers
  1. <!-- Script Language="JavaScript" Type="text/javascript" -->
  2.   // This JavaScript provides random movie links.
  3.   <!--
  4.   var rLink = new Array();
  5.   rLink[0] = "myVideo01";
  6.   rLink[1] = "myVideo02";
  7.  
  8.   var rVideo = Math.floor(Math.random() * rLink.length)
  9.   var rVLink = "'http://my.site.com/videos/" + rLink[rVideo] + ".html'"
  10.  
  11.   function rdmVideo()
  12.     {
  13.       document.write(rVLink)
  14.     }
  15.   //-->
  16. <!-- /Script -->
  17.  
index.html
========

[HTML]<HTML>
<Head>
<Title>My Site</Title>
</Head>
<Body BGColor="Black" Link="SkyBlue" Text="White">
<Script Language="JavaScript" Src="rdmMovie.js" Type="text/javascript">
</Script>
<A Class="menulink"
onMouseOver="window.status='View random video'; return true"
onClick="window.status=''; return true"
onMouseOut="window.status=''; return true"
Style="Cursor: hand"
Target="_blank"
HRef="javascript:rdmVideo()">[Click here to view random video</A>
</Body>
</HTML>
[/HTML]
I'm encountering a script error in the index.html document that indicates a "Function expected".

Any insight as to what is going wrong and how to correct it would be greatly appreciated.
Jun 17 '06 #1
3 3723
ljwheeler
3 New Member
I've been fighting this problem all day but can't seem to get it to work no matter what I try. I would think it would be very simple, but...

rdmMovie.js
===========

Expand|Select|Wrap|Line Numbers
  1. <!-- Script Language="JavaScript" Type="text/javascript" -->
  2. // This JavaScript provides random movie links.
  3. <!--
  4. var rLink = new Array();
  5. rLink[0] = "myVideo01";
  6. rLink[1] = "myVideo02";
  7.  
  8. var rVideo = Math.floor(Math.random() * rLink.length)
  9. var rVLink = "'http://my.site.com/videos/" + rLink[rVideo] + ".html'"
  10.  
  11. function rdmVideo()
  12. {
  13. document.write(rVLink)
  14. }
  15. //-->
  16. <!-- /Script -->
  17.  
index.html
==========

[HTML]<HTML>
<Head>
<Title>My Site</Title>
</Head>
<Body BGColor="Black" Link="SkyBlue" Text="White">
<Script Language="JavaScript" Src="rdmMovie.js" Type="text/javascript">
</Script>
<A Class="menulink"
onMouseOver="window.status='View random video'; return true"
onClick="window.status=''; return true"
onMouseOut="window.status=''; return true"
Style="Cursor: hand"
Target="_blank"
HRef="javascript:rdmVideo()">Click here to view random video</A>
</Body>
</HTML>[/HTML]

I'm encountering a script error in the index.html document that indicates a "Function expected".

Any insight as to what is going wrong and how to correct it would be greatly appreciated.
Jun 17 '06 #2
iam_clint
1,208 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1.  
  2. THE JAVASCRIPT
  3.  
  4. <!-- Script Language="JavaScript" Type="text/javascript" -->
  5. // This JavaScript provides random movie links.
  6. <!--
  7. function rdmVideo() {
  8.     var rLink = new Array();
  9.     rLink[0] = "myVideo01";
  10.     rLink[1] = "myVideo02";
  11.     var i = Math.floor(Math.random() * rLink.length);
  12.     rvLink = "http://my.site.com/videos/" + rLink[i] + ".html";
  13.     window.open(rvLink);
  14. }
  15. //-->
  16. <!-- /Script -->
  17.  
  18.  
  19. The HTML
  20.  
  21. <HTML>
  22. <Head>
  23. <Title>My Site</Title>
  24. </Head>
  25. <Body BGColor="Black" Link="SkyBlue" Text="White">
  26. <Script Language="JavaScript" Src="rdmMovie.js" Type="text/javascript">
  27. </Script>
  28. <A href="javascript: void(0);" onClick="rdmVideo();" Style="Cursor: hand" target="_blank" id="link">Click here to view random video</A>
  29. </Body>
  30. </HTML>
  31.  
Hope this helps you out. something i threw togethor for ya.
Jul 15 '06 #3
ljwheeler
3 New Member
Hey, thanks for the follow up. Your version looks pretty close to what I finally got working shortly after I placed my post. You can find it by going to my site at http://home.earthlink.net/~the.rocker/

You'll have to click on the initial index.html "banner" page to get to the actual page that shows my random movie link.

Thanks again!
Jul 16 '06 #4

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

Similar topics

3
by: ¤ Alias | last post by:
I have a function named getID3info (lvwDiscInfo.SelectedItem). What is the difference between getID3info (lvwDiscInfo.SelectedItem) and Call getID3info(lvwDiscInfo.SelectedItem) ?
1
by: Newgene | last post by:
Hi, group, I am trying to dynamically add a method to class by following this post: ...
5
by: Michael Stevens | last post by:
Probably the wrong wording but since I'm not a scripter I won't claim to know what I'm talking about. I got this script from www.htmlgoodies.com <script language="JavaScript"> <!--...
5
by: Rick | last post by:
I wrote the following code as part of a page where users can reorder a list of items by highlighting an item in a list box and clicking an "up" or "down" button to move the items around. The code...
4
by: Dmitry | last post by:
Hello, Sometimes on js code execution Mozilla 1.5 prints in JS concole the following error: "Error: fn is not defined" where "fn" is the function name surely defined _before_ the line that...
3
by: rdi | last post by:
The import statements weren't copy/pasted, but everything INSIDE the class WAS copy pasted from the help file. Starting with the myMail.From line and going down to the SmtpMail.Send line, EVERY line...
3
by: Jon | last post by:
I'm learning about datatables. When using the example provided by MS in the ..NET Framework Class Library for DATATABLE (see below) I get an error on line 3 that says "Type expected". Is something...
28
by: fred.haab | last post by:
Not having server side scripting, I've been doing this for "last modified" tags on my pages: <div class="modified"> <script type="Text/JavaScript"> <!-- document.write("This page was last...
16
by: Steve Chapel | last post by:
When I load the page <https://bugzilla.mozilla.org/attachment.cgi?id=237739with Internet Explorer 7 RC 1, I get the error "Object Expected" at line 174. When I click on the button, I also get the...
9
by: erictheone | last post by:
Ok so what I'm trying to do is create a trans location cipher. For those among us that don't know alot about cryptography it is a method for jumbling up letters to disguise linguistic...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.