Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday, October 8, 2007

IFRAME without src attribute on HTTPS in Internet Explorer

Problem :
This took me quite some time to debug this problem, i think from the images source, but from code also, yess i found this problem solving.

If you have a webpage on a HTTPS server with the following iframe code where you leave the src out:
< iframe id="if">< /iframe>
and you view the page in Internet Explorer you'll get the following very descriptive warning.
This page contains both secure and nonsecure items
Clicking on the More Info button doesn't give you which items it's referring to, but just a help file.

Leaving the src attribute out of the iframe is common, when you want to fill the src attribute programmatically.

Solution :
Create a blank.html page and then write:
< iframe id="if" src="blank.html">< /iframe>
The blank.html only contains < html>< /html >

ps: no need to create blank.html is also work

DropDownList Selected Item - With Javascript

This code will help you to get text value from dropdownlist object

function ShowPPSalesmanUniformImage()
{
var ddlUnifDistributionCode = document.getElementById("ddlUnifDistributionCode");
// mengambil dropdown text dengan javascript
var strVal = ddlUnifDistributionCode.options[ddlUnifDistributionCode.selectedIndex].text;
showPopUp('../PopUp/PopUpSalesmanUniformImage.aspx?Distribution='+strVal,'',500,760,'');
}

Friday, September 21, 2007

Message Box on Web

We can generate button message with button confirmation using javasript code
and this is example code :

===================================================
< HEAD >
< title >Test Alert< /title >
< script language="javascript" >
< !-- Hide from non-JavaScript Browsers -- >
function ConfirmChoice()
{
answer = confirm("Do you really want to go here?")
if (answer !=0)
{
location = "anotherPage.html"
}
}
< /script >
< /HEAD >
< body MS_POSITIONING="GridLayout" >
< form id="Form1" method="post" runat="server" >
< input type="button" id="btnAlert" OnClick=" ConfirmChoice(); return false;" value="Alert" >
< /form >
< /body >

Tuesday, September 18, 2007

Bug On Javascript Variable

I found some unussual event, when i run my javascript,
when i use a same variable, it make loop forever,
so i decide to change it with different variable, and it run =)
this is my javascript code:
=============================================================

function NumOnlyBlurWithOnGridTxt(param1, addKey)
{
var key = document.getElementById(param1.id).value;
var newValue = "";
for (i=0;i<key.length;i++)
{
if ((key.charCodeAt(i) >=48 && key.charCodeAt(i)<=57) || (key.charCodeAt(i) == 0))
{
newValue = newValue + key.charAt(i);
}
else
{
if (isAccepted(key.charCodeAt(i),addKey))
{
newValue = newValue + key.charAt(i);
}
}
}
document.getElementById(param1.id).value = newValue;
}
// second function fixed, before i use variable "i" not "j"
function isAccepted(key,addKey)
{
if (addKey != "")
{
for (j=0;j<addKey.length;j++)
{

if (key == addKey.charCodeAt(j))
{
return true;
}

}
}
return false;
}

Hukum Tabur Tuai

Ingatlah hukum dasar ini, dalam kehidupanmu  Barang siapa yang menanam, dia pula yang akan menuai