Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7779171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:35:03+00:00 2026-06-01T18:35:03+00:00

I am a total beginner with Javascript and JQuery, and am trying to achieve

  • 0

I am a total beginner with Javascript and JQuery, and am trying to achieve the following:

In TinyMCE, I wish to be able to type the following:

  • Click here to watch video 1
  • [popup]path/to/file1.mp4
  • Click here to watch video 2
  • [popup]path/to/file2.mp4

JQuery would then use the [popup] hook to identify instances of where I want a dialog window, place an anchor to call that dialog, populate the dialog with a call to JWPlayer, and feed the path given in each instance to it. It is in the storing of each URL, and subsequently giving that exact URL to the player that I am having great difficulty.

Managed to get it going in the end – no doubt more elegant solutions exist. Thx to Ben below for bringing me along.

UPDATED WITH WORKING SOLUTION: The current code:

$(document).ready(function(){

var num = 0;

//Find [popup] instances, increment the number
$("li:contains('[popup]')").each(function() {
    var nextnumber = num++;

    //add a general and a unique class to the list item containing the hook
    //this leaves only the path to file in that list item.
    $(this).addClass('popup' + ' ' + 'pop' + nextnumber);

    //Split on the hook, and save remainder of text (the path to file) as the 'path' attr
    var splitpath = $(this).text().split("[popup]");
    $(this).attr("path", splitpath[1]); 
    var path = $(this).attr("path");
    //alert($(this).attr("path"));

    //Get the previous list item (the call to action), and give it general and unique classes also.
    $thisArrow = $(this).parent().prev();
    $thisArrow.addClass('arrow' + ' ' + 'arr' + nextnumber);

    //Make the call to action an anchor link, with a general class identifier.
    $thisArrow.wrapInner('<a class="opener" title="Click to view video" path ="' + path + '"/>');

    //store path to poster as var, and hide the .popup li's
    $('li.popup').parent().hide();
});

$('.opener').click(function() {
    var Header = $(this).text();
    var popupURL = $(this).attr("path");
    var popupBG = "../contents/css/images/white-nontrans.jpg";

var thisDialog = $('<div></div>')

   //N.B. THE FOLLOWING HTML SHOULD BE ENTIRELY INCLUDED IN THE SINGLE .HTML() CALL
   //Otherwise Jquery will automatically close the <object> after the first line

   .html('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="mediaplayer1" name="mediaplayer1" width="550" height="420">')
.append('<param name="movie" value="../mediaplayer/player.swf">')    
.append('<param name="allowfullscreen" value="true">')
.append('<param name="allowscriptaccess" value="always">')
.append('<param name="bgcolor" value="#FFFFFF">')
.append('<param name="wmode" value="opaque">') 
.append('<param name="flashvars" value="file=' + popupURL + '&image=' + popupBG + '">') 
.append('<embed id="mediaplayer1" name="mediaplayer2" src="../mediaplayer/player.swf" width="550" height="420" allowfullscreen="true" allowscriptaccess="always" bgcolor="#FFFFFF" wmode="opaque" flashvars="file=' + popupURL + '&image=' + popupBG + '" />')
.append('</object>')

.dialog({ autoOpen: false, title: Header, modal: true, width:570 });
thisDialog.dialog('open');
    return false;
});
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:35:04+00:00Added an answer on June 1, 2026 at 6:35 pm

    Relatively straightforward. In the function that converts your [popup] hooks, define a var counter = 0 prior to your .each loop. Inside the loop, iterate the counter, and use that number to generate the unique data/markings, which you apply from within the loop.

    This is a pretty brief description of the solution. If you need more detail, just let me know.

    edit: It seems like the problem would not be in the storage itself, but in identifying and getting control of the URL. You should be able to store the url in an arbitrarily named attribute in the anchor tag. It will be a technically “illegal” tag, so it won’t do anything, but it will be there, it won’t interfere with anything, and you’ll be able to pull it out easily with the jquery .attr() function.

    Getting the URL itself so that you can put it into your attribute of choice is probably best done using javascript’s split(). First, split on “[popup]”. This will give you an array where the first element begins at the beginning of the text block, and each subsequent element begins immediately after a “[popup]”. Then split each of those (other than the first) on ‘ ‘. This will give you an array of that element, split by spaces – meaning that the first element in the array (as you’ve described it to me) should be the URL you’re looking for.

    edit2:

    $("li:contains('[popup]')").each(function() {
        var text = $(this).text();
        //by my understanding of split(), the [0] element in the array would be the
        //bit before the "[popup]" string, so we want the [1] element. 
        var splittext = text.split("[popup]")[1];
        var splitsplittext = splittext.split[" "];
        //by my understanding of the way you've presented the use rules, the [0]
        //element of splitsplittext ought to contain your path now.  If you want
        //to make it more robust (say, allowing the user to put an optional space
        //between the "[popup]" and the path) then the logic here gets more
        //complicated.
        $(this).attr("pathHolder", splitsplittext[0]); 
    }
    

    Once you’ve done that, any time you have the <li>, you can call $liNode.attr("pathholder") to get back the address string

    edit3: a few thoughts…
    – You’re setting multiple classes by adding in spaces manually. My understanding of good coding practice suggests that you should just call addClass multiple times.
    – You’re doing a lot of things with selectors that you should be doing with variables. For example, you use $('li.pop'+nextnumber) when you could just continue to use $(this). You add a class to an arrow just so you can use $('li.arr'+nextnumber) when you could just say something like $thisArrow = $(this).prev() and then used $thisArrow when you needed to refer to the thing.
    – when you’re defining the dialog, you don’t need to use var $dialog = – you only ever need var or the $. var means it’s a javascript variable, which means it’s strongly scoped. The $ means it’s a JQuery object, which means that it’s essentially scoped to the page. Unfortunately, neither would work well for you here, as your code is written. The javascript version would destroy itself almost immediately, as you cane to the end of the function, and the JQuery version would overwrite itself on the next cycle of the each loop. In order to preserve it properly, you’re going to have to actually write it in somewhere. Also, I’m pretty sure that JQuery is going to look at $('<div></div>') and just get confused. It looks like it’s trying to be a selector and failing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a total beginner with OpenCL and I'm trying to make the following kernel
I'm a total beginner to JavaScript, jQuery, and everything else, so when I saw
I am a total total beginner in Java actually I am .net dev trying
I'm pretty new to Java and am following the Eclipse Total Beginner's Tutorials .
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I'm total beginner in js and JQuery and have to complete such task: I
I'm trying to get WCF working with Silverlight. I'm a total beginner to WCF
I am trying to use VIM for some programming. I am a total beginner
im a total beginner in web programming. Im trying to create a simple website
I have stumped on this as I am a total beginner in MySql. Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.