4

Here is the rundown of the problem:

console.log($("#clippy")); //For testing purposes. The element is properly selected.

//Next, I need to grab the text value I want to be copied into the clipboard...
var textToCopy = $(".permalink input[name='link']").text();

//How can I paste the value inside textToCopy inside the appropriate areas:
//Here's the exact HTML I need to manipulate, with the two params I need to modify.
//Labeled: "<-----HERE!"

/*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
        width="110"
        height="25"
        id="clippy" >
    <param name="movie" value="/flash/clippy.swf"/>
    <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param NAME="FlashVars" value="text=sergio is the best champ"> <-------HERE!
    <param name="bgcolor" value="#fff">
    <embed src="../../Public/javascripts/clippy.swf"
            width="110"
            height="25"
            name="clippy"
            quality="high"
            allowScriptAccess="always"
            type="application/x-shockwave-flash"
            pluginspage="http://www.macromedia.com/go/getflashplayer"
            FlashVars="text=sergio is the best champ" <--------AND HERE!
            bgcolor="#fff"
    />
</object>*/

Assuming the value of textToCopy was "Welcome to The Matrix.", this would be the resulting HTML:

 /*<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
        width="110"
        height="25"
        id="clippy" >
    <param name="movie" value="/flash/clippy.swf"/>
    <param name="allowScriptAccess" value="always" />
    <param name="quality" value="high" />
    <param name="scale" value="noscale" />
    <param NAME="FlashVars" value="text=Welcome to The Matrix."> <-------HERE!
    <param name="bgcolor" value="#fff">
    <embed src="../../Public/javascripts/clippy.swf"
            width="110"
            height="25"
            name="clippy"
            quality="high"
            allowScriptAccess="always"
            type="application/x-shockwave-flash"
            pluginspage="http://www.macromedia.com/go/getflashplayer"
            FlashVars="text=Welcome to The Matrix." <--------AND HERE!
            bgcolor="#fff"
    />
</object>*/
3
  • 2
    $('#clippy').find('param[name="FlashVars"]').val(textToCopy); and $('#clippy').find('embed').attr('FlashVars', textToCopy); Commented Apr 27, 2012 at 21:04
  • I found this: stackoverflow.com/questions/1081656/object-param-jquery. See answer 3. Commented Apr 27, 2012 at 21:05
  • @Ohgodwhy Can you post this as an answer? Commented Apr 27, 2012 at 21:10

1 Answer 1

6

You can access the parameters of an object by finding the param by name:

$('#clippy').find('param[name="FlashVars"]').val(textToCopy); 

You can access the attributes of the embed within the object like this:

$('#clippy').find('embed').attr('FlashVars', textToCopy);
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, this is now properly setting the data in the HTML as I need it. However the lib is copying the text set when the page is first rendered, not the text that is set via this jQuery code. Do I need to somehow reload clippy library in order for it to copy the text I added in dynamically after the page loaded?
Could you create a jsFiddle with your problem? You can include the library for clippy there. Then I could give you a better explanation as to why you're experiencing what you're experiencing. I've never used clippy.
Sure I'll do that and post a comment here with the link. Thanks for your time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.