Search results for 'HTML, Javascript'. 72 post(s) found.

  1. 2009/09/14 Photoshop script programming in Javascript
  2. 2009/08/28 To compare two HTML tables on web page in real time
  3. 2009/08/28 To hide/show area of web page without re-loading a page
  4. 2009/08/28 Displays the html tags without rendering on a webpage
  5. 2009/08/28 Javascript based query parser for AJAX application
  6. 2009/08/28 To get web browser capability
  7. 2009/08/28 Photo thumbnail viewer implement in javascript
  8. 2009/08/22 Javascript Confirmation
  9. 2009/08/22 Javascript Prompts
  10. 2009/08/22 How to know browser version in javascript ?
2009/09/14 20:03

Photoshop script programming in Javascript


Adobe Photoshop provides the strong functions as javascript function for extension. In case of developing web based photo editing application, you can use it with javascript easily.

Follwing is the first step to use Photoshop Scripting:

<script>

if (BridgeTalk.appname == "Photoshop")
{
  // then you can do something for photo
}

</script>

As you can see above, you can simply check whether Photoshop Script is available or not.
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2009/08/28 09:03

To compare two HTML tables on web page in real time


When you need to compare two tables on web page, you can simply read the content with innerHTML tag easily. But you need to analyze the table content. Following is the simple example to analyze two table content.

<script lanugage="text/javascript">
function CompareTables(table1,table2)
{
  var instHasChange = false;
  for(var i=0; i < table1.rows.length; i++)
  {
    var changes =RowExists(table2,table1.rows[i].cells[0].innerHTML,table1.rows[i].cells[1].innerHTML);
    if(!changes[0])
    {
     table1.rows[i].style.backgroundColor = "red";
     instHasChange = true;
    }
    else if(changes[1])
    {
    table1.rows[i].style.backgroundColor = "orange";
    instHasChange = true;
    }
  }
  for(var i=0; i < table2.rows.length; i++)
  {
    var changes = RowExists(table1,table2.rows[i].cells[0].innerHTML,table2.rows[i].cells[1].innerHTML);
    if(!changes[0])
    {
     table2.rows[i].style.backgroundColor = "#00CC33";
     instHasChange = true;
    }
    else if(changes[1])
    {
    table2.rows[i].style.backgroundColor = "orange";
    instHasChange = true;
    }
  }
  return instHasChange;
}

function RowExists(table,columnName,columnValue)
{
  var hasColumnOrChange = new Array(2);
  hasColumnOrChange[0] = false;
  hasColumnOrChange[1] = false;
  for(var i=0; i < table.rows.length; i++)
  {
    if(table.rows[i].cells[0].innerHTML == columnName)
    {
    hasColumnOrChange[0] = true;
    if(table.rows[i].cells[1].innerHTML != columnValue)
    hasColumnOrChange[1] = true;
    }
  }
  return hasColumnOrChange;
}
</script>

Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2009/08/28 08:45

To hide/show area of web page without re-loading a page


You can simply show and hide by changing style.display property. By calling below javascript function from the header row of your table, you can make your table collapsible.

<script language="text/javascript">
function ExpandCollapseTable(titleRow)
{
  if(titleRow.parentNode.childNodes.length > 1)
  {
    if(titleRow.parentNode.childNodes[1].style.display=="block" || titleRow.parentNode.childNodes[1].style.display=="")
    {
     for(var i=1;i<titleRow.parentNode.childNodes.length;i++)
     {
       titleRow.parentNode.childNodes[i].style.display = "none";
     }
    }
    else
    {
     for(var i=1;i<titleRow.parentNode.childNodes.length;i++)
     {
       titleRow.parentNode.childNodes[i].style.display = "block";
     }
    }
  }
}
</script>

Following is HTML body calling above function.
<body>
  <table border=1>
    <tr onclick="ExpandCollapseTable(this);" style="cursor:pointer;">
      <td colspan=3>
        Table Header(click to expand-collapse)
      </td>
    </tr>
    <tr>
      <td style="width: 100px">1</td>
      <td style="width: 100px">2</td>
      <td style="width: 100px">3</td>
    </tr>
    <tr>
      <td style="width: 100px">4</td>
      <td style="width: 100px">5</td>
      <td style="width: 100px">6</td>
    </tr>
    <tr>
      <td style="width: 100px">7</td>
      <td style="width: 100px">8</td>
      <td style="width: 100px">9</td>
    </tr>
  </table>
</body>
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2009/08/28 08:36

Displays the html tags without rendering on a webpage


Following code display the HTML Tags without additonal web page rendering.

<script type="text/javascript">
function firstMethod()
{
  var str = document.getElementById("tbl").innerHTML.replace(/[<]/g,'&lt;');
  str = str.replace(/[>]/g,'&gt;');
  document.getElementById("displayHTML").innerHTML = str;
}
function secondMethod()
{
  document.getElementById("displayHTML").innerText = document.getElementById("tbl").innerHTML;
}
</script>

.
.
.

<body>
  <div id="displayHTML"></div>
  <table border="1" id="tbl">
    <tr>
      <td style="width: 100px">
        1</td>
      <td style="width: 100px">
        2</td>
      <td style="width: 100px">
        3</td>
    </tr>
    <tr>
      <td style="width: 100px">
        4</td>
      <td style="width: 100px">
        5</td>
      <td style="width: 100px">
        6</td>
    </tr>
    <tr>
      <td style="width: 100px">
        7</td>
      <td style="width: 100px">
        8</td>
      <td style="width: 100px">
        9</td>
    </tr>
  </table>
  <input type="button" value="use conventional method" onclick="firstMethod()" />
  <input type="button" value="use serkan's method" onclick="secondMethod()" />
</body>


This is a good example of using javascript innerText property which is not
as popular as innerHTML property.
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2009/08/28 08:32

Javascript based query parser for AJAX application


When you want to pass data from one web page to another when server-side scripting is not available, and without setting a cookie? Here's the really good javascript you can use.

<script>
function QueryParser(str)
{
  if (str)
  {
    str = unescape(str);
    if (str.indexOf("?") === 0)
    {
      str = str.substring(1);
    }
    var args = str.split("&");
    for (var i = 0; i < args.length; i++)
    {
      var pair = args[i].split("=");
      if (pair.length >= 1)
      {
        var prop = pair.shift();
        this[prop] = (pair.length == 1) ? pair[0] : (pair.length > 1) ? pair.join('=') : '';
      }
    }
  }
  this.set = function (prop, value) { return this[prop] = value; };
  this.clear = function (prop)
  {
    if(typeof this[prop] !== 'undefined')
    {
      this.set(prop, null);
      return true;
    }
    else { return false; }
  };
  this.build = function (baseURL, hashName)
  {
    baseURL = (!baseURL || typeof baseURL !== 'string') ? '?' : (baseURL.indexOf("?") === -1) ? (baseURL + '?') : baseURL;
    hashName = (!hashName || typeof hashName !== 'string') ? '' : (hashName.indexOf("#") === -1) ? ('#' + hashName) :

hashName;
    var strArray = [];
    for (var prop in this)
    {
      if (typeof this[prop] !== 'undefined' && typeof this[prop] !== 'function' && this[prop] !== null)
      {
        strArray.push([prop, '=', this[prop]].join(''));
      }
    }
    return baseURL + strArray.join('&') + hashName;
  };
  this.buildLink = function (baseURL, linkTxt)
  {
    var url = this.build(baseURL);
    return [ '<a href="', url, '">', ((!linkTxt) ? url : linkTxt), '</a>' ].join('');
  };
}
var $q = new QueryParser(location.search);
</script>


Following is the simple example for above javascript.

EXAMPLE
URL: http://www.mydomain.com/mydir/page.h...&potential=110
$q.name will hold the value 'Super Coder'
$q.rank will hold the value '9999999999'
$q.potential will hold the value '110'
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.