Results 1 to 6 of 6

Thread: HTML5 Custom attribute question

  1. #1
    Join Date
    Nov 2009

    HTML5 Custom attribute question

    Hello everyone,

    Quick question, can an HTML5 Custom attribute be posted to another page? Like what you would do with php's $_POST method?

    If so, how can you use the data on the linked page, how would you call it?


  2. #2
    Join Date
    Dec 2012
    The data attribute can only be used in JavaScript, if you want to pass it to another page you could do so by appending the value in the URL as a $_GET variable or by using AJAX.

  3. #3
    Join Date
    Nov 2009
    Yeah, that's what I thought, I know about $_GET but I'm trying to keep the URL as clean as possible.

    I have never ever used AJAX for anything, is it complicated to do it this way?

  4. #4
    Join Date
    Dec 2012
    AJAX is used to send a request out to another page of your website receiving some kind of response back, without leaving the page the request was sent from.

    It isn't particularly difficult, it just might not be what you're after.

    Here's a quick ajax example, you open the page you want to send the request to appending your variables into the URL, then send the request, wait for a response, then do whatever with the response you get from the page.

    var ajax = new XMLHttpRequest;
    ajax.onreadystatechange = function() {
         if(ajax.readyState == 4 && ajax.status == 200) {

  5. #5
    Join Date
    Nov 2009
    Yeah, that might not do what I need, I'll look into it a little further, might be a good chance to start learning a little AJAX though...


  6. #6
    Join Date
    Apr 2013
    Custom attributes are among the most significant additions for HTML5, and can play a major role in semantic Web development.
    If you donít already have one you want to use, copy the following outline into an HTML file:
    <!DOCTYPE html>
    /*functions here*/

    You will place your elements with custom attributes in the body and the JavaScript functions for accessing them in the head section script area.
    For Creating Element:
    <div id="product1" data-product-category="clothing">
    Cotton Shirt
    <input type="button" value="get attribute" onclick="getElementAttribute('product1')"/>

Thread Information

Users Browsing this Thread

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

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