www.webdeveloper.com
Results 1 to 2 of 2

Thread: Alternative way for this script?

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    1

    Unhappy Alternative way for this script?

    Hi folks!
    I'm having some trouble with my users not being able to get a script working. It's a script where a user has to click an add to activate a link for a download.

    It was working fine until a week ago, and after that users have had alot of trouble getting the script to work.

    It looks like this:

    Code:
    <script language="javascript">
    function activateLink(obj){
    myDiv=document.getElementById(obj);
    myDiv.innerHTML='<a href="'+myDiv.attributes["value"].nodeValue+'" target=_blank>'+myDiv.innerHTML+'</a>';
    }
    </script>
    
    <div id=link2>[include file="ad1.php"]</div><p>
    <div id=link1 style="font-family: impact; font-size: 28px;" value="http://#/wp-content/plugins/download-monitor/download.php?id=79">Ladda Ner</div></p>
    The included file looks like this:
    Code:
    <a href="#" onclick="activateLink('link1');" target="_blank"><img src="#/wp-content/uploads/2011/04/103381.jpg" alt="Klicka här" border="0" /></a>
    If you want to see the code active, visit http://www.designadinblogg.se/gratisdesign/?p=659 and click on the ad (Aha-bingo.com).
    When you click it, the download link (Ladda Ner) will be activated.

    Is there a way to modify the script, or just to get it to work at all times?

  2. #2
    Join Date
    May 2011
    Posts
    194

    DIV and .value

    Hi,

    <script language="javascript">

    function activateLink(stIdOfAnObject)
    // stIdOfAnObject must be != null and != ""
    // object must have
    // .innerHTML (DIV yes)
    // .attribute (collection) (DIV yes)
    // .value (index of collection) (DIV no)
    {
    var ptObject=document.getElementById(stIdOfAnObject); // must be != null
    var stNodeValue=ptObject.attributes["value"].nodeValue; // ptObject.attributes["value"] must be != null
    var stInnerHTMLOld=ptObject.innerHTML; // default value exists (before first set .innerHTML) ?

    ptObject.innerHTML='<a href="'+ stNodeValue +'" target=_blank>'+stInnerHTMLOld+'</a>';
    }
    </script>

    ----------------------------------

    <div id="link2"> ....

    ----------------------------------

    <div id=link1 style="font-family: impact; font-size: 28px;" value="http://#/ .....

    value ???

    ----------------------------------


    for Microsoft Internet Explorer http://msdn.microsoft.com/en-us/library/ms533050.aspx


    DIV Element | div Object

    Attribute Property Description
    ACCESSKEY accessKey Sets or retrieves the accelerator key for the object.
    ALIGN align Sets or retrieves the alignment of the object relative to the display or table.
    ATOMICSELECTION Specifies whether the element and its contents must be selected as a whole, indivisible unit.
    BEGIN begin Sets or retrieves the delay time before the timeline begins playing on the element.
    blockDirection Retrieves a string value that indicates whether the content in the block element flows from left to right, or from right to left.
    canHaveChildren Retrieves a value indicating whether the object can contain children.
    canHaveHTML Sets or retrieves the value indicating whether the object can contain rich HTML markup.
    CLASS className Sets or retrieves the class of the object.
    clientHeight Retrieves the height of the object including padding, but not including margin, border, or scroll bar.
    clientLeft Retrieves the distance between the offsetLeft property and the true left side of the client area.
    clientTop Retrieves the distance between the offsetTop property and the true top of the client area.
    clientWidth Retrieves the width of the object including padding, but not including margin, border, or scroll bar.
    CONTENTEDITABLE contentEditable Sets or retrieves the string that indicates whether the user can edit the content of the object.
    DATAFLD dataFld Sets or retrieves which field of a given data source, as specified by the dataSrc property, to bind to the specified object.
    DATAFORMATAS dataFormatAs Sets or retrieves how to render the data supplied to the object.
    DATASRC dataSrc Sets or retrieves the source of the data for data binding.
    DIR dir Sets or retrieves the reading order of the object.
    disabled Sets or retrieves the value that indicates whether the user can interact with the object.
    DISABLED disabled Sets or retrieves the status of the object.
    END end Sets or retrieves a value indicating the end time for the element, or the end of the simple duration when the element is set to repeat.
    firstChild Retrieves a reference to the first child in the childNodes collection of the object.
    hasMedia Retrieves a Boolean value that indicates whether the element is an Introduction to HTML+TIME media element.
    HIDEFOCUS hideFocus Sets or retrieves the value indicating whether the object visibly indicates that it has focus.
    ID id Retrieves the string identifying the object.
    innerHTML Sets or retrieves the HTML between the start and end tags of the object.
    innerText Sets or retrieves the text between the start and end tags of the object.
    isContentEditable Retrieves the value indicating whether the user can edit the contents of the object.
    isDisabled Retrieves the value indicating whether the user can interact with the object.
    isMultiLine Retrieves the value indicating whether the content of the object contains one or more lines.
    isTextEdit Retrieves whether a TextRange object can be created using the object.
    LANG lang Sets or retrieves the language to use.
    LANGUAGE language Sets or retrieves the language in which the current script is written.
    lastChild Retrieves a reference to the last child in the childNodes collection of an object.
    nextSibling Retrieves a reference to the next child of the parent for the object.
    nodeName Retrieves the name of a particular type of node.
    nodeType Retrieves the type of the requested node.
    nodeValue Sets or retrieves the value of a node.
    NOWRAP noWrap Sets or retrieves whether the browser automatically performs wordwrap.
    offsetHeight Retrieves the height of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
    offsetLeft Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
    offsetParent Retrieves a reference to the container object that defines the offsetTop and offsetLeft properties of the object.
    offsetTop Retrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
    offsetWidth Retrieves the width of the object relative to the layout or coordinate parent, as specified by the offsetParent property.
    onOffBehavior Retrieves an object indicating whether the specified Microsoft® DirectAnimation® behavior is running.
    outerHTML Sets or retrieves the object and its content in HTML.
    outerText Sets or retrieves the text of the object.
    ownerDocument Sets or retrieves the document object associated with the node.
    parentElement Retrieves the parent object in the object hierarchy.
    parentNode Retrieves the parent object in the document hierarchy.
    parentTextEdit Retrieves the container object in the document hierarchy that can be used to create a TextRange containing the original object.
    previousSibling Retrieves a reference to the previous child of the parent for the object.
    readyState Retrieves the current state of the object.
    recordNumber Retrieves the ordinal record from the data set that generated the object.
    scopeName Retrieves the namespace defined for the element.
    scrollHeight Retrieves the scrolling height of the object.
    scrollLeft Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window.
    scrollTop Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window.
    scrollWidth Retrieves the scrolling width of the object.
    sourceIndex Retrieves the ordinal position of the object, in source order, as the object appears in the document's all collection.
    STYLE Sets an inline style for the element.
    SYNCMASTER syncMaster Sets or retrieves whether the time container must synchronize playback to this element.
    systemBitrate Retrieves the approximate bandwidth available to the system in bits-per-second.
    systemCaptions Indicates whether or not to display a text equivalent of the audio portion of the presentation.
    systemLanguage Indicates whether a given language is selected in a user's system preferences.
    systemOverdubOrSubtitle Specifies whether overdubs or subtitles render during a presentation.
    TABINDEX tabIndex Sets or retrieves the index that defines the tab order for the object.
    tagName Retrieves the tag name of the object.
    tagUrn Sets or retrieves the Uniform Resource Name (URN) specified in the namespace declaration.
    TIMECONTAINER timeContainer Sets or retrieves the type of timeline associated with an element.
    TITLE title Sets or retrieves advisory information (a ToolTip) for the object.
    uniqueID Retrieves an autogenerated, unique identifier for the object.
    UNSELECTABLE Specifies that an element cannot be selected.


    attributes Collection


    Syntax

    [ oColl = ] object.attributes
    [ oObject = ] object.attributes(iIndex)

    Possible Values

    oColl Zero-based array of attributes applied to the object.
    oObject Reference to an individual item in the array of elements contained by the object.
    iIndex Required. Integer that specifies the zero-based index of the item to be returned.


    Property Description
    length Sets or retrieves the number of objects in a collection.

    Method Description
    getNamedItem Retrieves an attribute specified with the name property using the attributes collection.
    item Retrieves an attribute for an element from the attributes collection.
    removeNamedItem Removes an attribute specified with the name property from an element using the attributes collection.
    setNamedItem Adds an attribute to an element using an attributes collection.

    <SCRIPT>
    function ShowAttribs(oElem)
    {
    txtAttribs.innerHTML = '';

    // Retrieve the collection of attributes for the specified object.
    var oAttribs = oElem.attributes;

    // Iterate through the collection.
    for (var i = 0; i < oAttribs.length; i++)
    {
    var oAttrib = oAttribs[i];

    // Print the name and value of the attribute.
    // Additionally print whether or not the attribute was specified
    // in HTML or script.
    txtAttribs.innerHTML += oAttrib.nodeName + '=' +
    oAttrib.nodeValue + ' (' + oAttrib.specified + ')<BR>';
    }
    }
    </SCRIPT>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles