SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: How can I create embed code?

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Location
    Melbourne, Australia
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I create embed code?

    So I've come across something which I need to find for a project which would also be very useful in general. How can I create the embed code which has the ability to be copied? I require something similar to the youtube embed code snippet, where you can click on the embed area, it highlights the content for you to copy. I've been doing some searching but can't find much as yet.

  2. #2
    It's all Geek to me silver trophybronze trophy
    SitePoint Award Recipient ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, Australia
    Posts
    19,947
    Mentioned
    216 Post(s)
    Tagged
    2 Thread(s)
    The most likely way to do that would be with JavaScript, so your thread has been moved to that forum.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Location
    Melbourne, Australia
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To clarify a bit, basically I need to be able to put a code snippet of html into a website which can then be copied. I guess similar to the ones where you see then on tutorial and example sites.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2010
    Location
    Melbourne, Australia
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <textarea name="textarea" cols="40" rows="4" wrap="VIRTUAL" readonly="readonly">Code here</textarea>
    I tried this however when you click inside it the text vanishes, any ideas so that it doesn't vanish and instead you can copy it?

    Edit: Might be read only, will test and get back here.

  5. #5
    Unobtrusively zen silver trophybronze trophy
    SitePoint Award Recipient paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,203
    Mentioned
    40 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AirFor View Post
    Code:
    <textarea name="textarea" cols="40" rows="4" wrap="VIRTUAL" readonly="readonly">Code here</textarea>
    I tried this however when you click inside it the text vanishes, any ideas so that it doesn't vanish and instead you can copy it?

    Edit: Might be read only, will test and get back here.
    Is there something else on the page that's causing it to vanish? The testing that I've done with the snippet you posted doesn't show any any symptoms of things vanishing.

    Here's a good simple example:

    HTML Code:
    <textarea id="embedcode" cols="40" rows="4" wrap="VIRTUAL" readonly="readonly">Code here</textarea>
    Code javascript:
    var embedcode = document.getElementById('embedcode');
    embedcode.onclick = function () {
        this.select();
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •