|
Sorry about for those removals, won't happend again...
I removesd the loop and now the code works as it should be working,
Thank you all.'
GBY: Olli.
|
|
|
|
|
Hi all,
is there any issue that you comes with chrome and IE when setting script with innerHtml in div element?
I'll explain it in this way.
I've define my own div element as popup message (just by floating on top of the page) and works fine. I can set html text on it as well properly. But when I set some script on it, FF works fine but chrome and IE not works fine. Anyone of you have an idea about that?
Hope you are clear with my issue, if not please let me know.
Thanks
I appreciate your help all the time...
CodingLover
modified on Thursday, April 28, 2011 5:11 AM
|
|
|
|
|
Can you provide an example that doesn't work in IE? Until then, here are some general guidelines:
Use "innerHTML", not "innerHtml".
Use createElement, set its innerHTML, then add it to the DOM, rather than adding the element to the DOM then setting the innerHTML. So, do this:
var newDiv = document.createElement("div");
newDiv.innerHTML = "Hello, <b>World</b>.";
var oldDiv = document.getElementById("myDiv");
oldDiv.parentNode.insertBefore(newDiv, oldDiv);
oldDiv.parentNode.removeChild(oldDiv);
newDiv.id = "myDiv";
Alternatively, avoid the use of innerHTML completely:
var mainDiv = document.getElementById("myDiv");
mainDiv.appendChild(document.createTextNode("Hello, "));
var boldWorld = document.createElement("b");
boldWorld.appendChild(document.createTextNode("World"));
mainDiv.appendChild(boldWorld);
mainDiv.appendChild(document.createTextNode("."));
Here is a hack that may or may not work:
var mainDiv = document.getElementById("myDiv");
mainDiv.innerHTML = "Hello <b>World</b>.";
mainDiv.innerHTML = mainDiv.innerHTML;
Depending on your specific issue, I've also seen hacks that modify the z-index so the browser knows to refresh the content.
|
|
|
|
|
Thanks for the reply.
AspDotNetDev wrote: Use "innerHTML", not "innerHtml".
Sorry about that, by mistake I've type it.
Say my string is something like this, it's working actually.
newDiv.innerHTML = "<script>function call_Al(){alert('this is a message');}</script><a href=\"#\" onclick=\"call_Al();\" >Click Here</a>"
I appreciate your help all the time...
CodingLover
|
|
|
|
|
This is not a bug rather a safety feature. You cannot add javascript code dynamically to a page after it has been rendered. Which means you can put the script content on the innerHTML, but it will not be processed by the script engine.
The only way I know of to dynamically add more script to a page after the initial page render is by using eval on the script string. Keep in mind though that means that the script you are adding is being executed.
|
|
|
|
|
Thanks for the comment.
can you have a look at in my previous reply. I try to wrap the string with eval() function, but it wont work too. I'm totally lost.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You should only apply the eval on the script code part. So excluding any HTML. In your case you would have to try and split the javascript code from the string you are trying to append and eval that.
You would append <a href=\"#\" önclick=\"call_Al();\" >Click Here</a> this part to the innerHTML attribute and pass the content of the javascript to the eval statement. Keep in mind you will need to rewrite your javascript slightly to:
eval("call_Al = function() { alert('this is a message'); }");
|
|
|
|
|
Gerben Jongerius wrote: You would append <a href=\"#\" önclick=\"call_Al();\" >Click Here</a> this part to the innerHTML attribute and pass the content of the javascript to the eval statement. Keep in mind you will need to rewrite your javascript slightly to:
I never know that. I try to bind all html and script together.
Anyway I've redesign my code, and now it works fine. Thanks a lot.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
I'm starting to test the new Dynamics CRM 2011 ; i'd like to figure out whether it could be useful for our needs.
I'm facing a problem since a couple of days : in the previous version, I could customize the time-pickers to show different time interval (default is 30 minutes).
But I can't find the right syntax for the 2011 version.
Here's my script :
var schedstart = Xrm.Page.getAttribute("scheduledstart");
var interval = 15;
var timeField;
var tables;
var table;
var row;
var cell;
var time;
if (schedstart != null)
{
timeField = schedstart.all.time;
if (timeField != null)
{
tables = timeField.getElementsByTagName("table");
if ((tables != null) && (tables.length > 0))
{
table = tables[1];
while (table.firstChild != null)
{
table.removeChild(table.firstChild);
}
for (hour = 0; hour < 24; hour++)
{
for (min = 0; min < 60; min += interval)
{
row = table.insertRow();
cell = row.insertCell();
time = ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
cell.setAttribute("val", time);
cell.innerText = time;
}
}
}
}
}
The problem is on line timeField = schedstart.all.time; . I've been searching for a reference document about manipulating form elements, but none of them does talk about datetime fields. I got plenty of examples if I want to deal whith lookups, optionsets, text, etc. ; but complete blackout about datetime fields.
Does anyone have an idea about how to access the time-picker of a datetime field in javascript ?
Edit :
I found how to manage this requirement. Here's the code :
setTimeInterval: function (ctrl, interval)
{
var control = Xrm.Page.getControl(ctrl);
var timeField = control._control._element.children[0].children[1].all.time.children[1].firstChild;
var row;
var cell;
var time;
if (timeField != null)
{
while (timeField.firstChild != null)
timeField.removeChild(timeField.firstChild);
for (hour = 0; hour < 24; hour++)
{
for (min = 0; min < 60; min += interval)
{
row = timeField.insertRow();
cell = row.insertCell();
time = ((hour < 10) ? "0" : "") + hour + ":" + ((min < 10) ? "0" : "") + min;
cell.setAttribute("val", time);
cell.innerText = time;
}
}
}
}
Hope this will be useful to someone
|
|
|
|
|
|
Thanks for your reply. Unfortunately, it isn't a native HTML5 time field.
I'll keep trying to access the table cell where the combo box resides.
|
|
|
|
|
Any one know how to use the setdata on ajaxupload...pls help
|
|
|
|
|
|
hi ,
i just want to show calander on page.
how can i do it..?
|
|
|
|
|
|
You might also want to try this JQuery plugin. It provides you the power and ease of JQuery + support of the development community.
|
|
|
|
|
Why do so many people put all their javascript into just one line of code?
Is there a noticeable speed increase?
I also read that putting comments into your javascript slows it down. Is that really true?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
A minimized javascript file does load faster because it has fewer characters to transmit across the wire. Also why comments are removed, the javascript engine ignores them anyway. That's why you typically see two javascript files, like script.js and script.debug.js. the latter of course being used for debugging situations were it has full comments and formatting for readbility.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Unfortunately, the shadowbox source code does not include a "debug" file. They also use single-character variable names. It's virtually impossible to figure out what's being done and what it's doing it to.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
A form of obfuscation
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
My answer is yes to all your questions. Removing unnecessary characters from javascript is known as minification and it does improve performance (I myself noticed this in one of my projects). Hence by the same logic removing comments will also improve performance.
Also this is one of the suggest best-practices by Yahoo.
|
|
|
|
|
I want to add browse for folder control in my web page.In HTML,browsing to the file level is there.But I need to browse the folder & want to get the complete path of that folder in web page.This folder can be in my local PC or can be in other pc in the network.Is this possible with java script or any other language???
I have to implement this feature anyhow.So any help is appreciated.If there is a solution in other languages like java,VC++ ,then please let me know.
Thanks in advance..
|
|
|
|
|
I don't believe there is a solution to this. The browser is of course using the capabilities of the client system and the default is for the FileOpen dialog, not the Folder dialog. To correct this you would need to install something on the client machine, very unlikely, or at the least use an ActiveX control, which is unlikely to be allowed either.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
new AjaxUpload("#fuCondition", {
action: servicesPath + 'Handlers/FileUpload.ashx?t=0&BRH_ID='+ $("#BRH_ID").val()+"&USR_ID="+ $("#USR_ID").val()+"&DeedOffice="+ $("#DeedOf").val(),
name: 'userfile',
data: {},
autoSubmit: true,
responseType: false,
onChange: function (file, extension) {
$("#fuCondition").hide();
$("#Uploading").show();
},
onSubmit: function (file, extension) {
if (!(extension && /^(rtf|zip)$/.test(extension))) {
alert('Error: file type not allowed.');
return false;
}
this.disable();
},
onComplete: function (file, response) {
$('#file_name').val(file);
if (response.toLowerCase() != 'true') {
$('#status').hide();
setTimeout(3000, 6000);
$("#Uploading").hide();
$("#fuCondition").show();
}
else if (response.toLowerCase() == 'false')
$('#status').html('error!, file not saved');
else
$("#status").html(response);
}
});
How to set the autosubmit to false, so that the plugin dsnt take defualt values of textbox? some links will be cool
modified on Thursday, April 21, 2011 8:42 AM
|
|
|
|
|
Please edit your post and format your code snippets using the "code block" toolbar item.
I know the language. I've read a book. - _Madmatt
|
|
|
|