|
No, that would break the security barrier between a browser and client system.
|
|
|
|
|
Gouranga Das wrote: Can we use java-script/JQuery for interfacing with Hardware device API installed on client system.
The answer is that it depends on what you are doing.
For instance if you are writing application or server side javascript (node.js[^]) then the answer is yes you can do this.
Another example is writing mobile applications written in HTML and javascript for mobile platforms. In this case you can use phonegap[^] which will give you access to certain hardware features of the device.
If you are purely doing web development with pages delivered from a server then the answer will be No (for now) as it violates the sandbox security put in place by the browser.
|
|
|
|
|
Also should have noted that it depends on the browser you are using...
I forgot that with Chrome you can do some stuff with the local hardware. An example is that I have some pinocc.io[^] boards and they are initially configured from a web page that uses chrome features. I have also read some articles in the past where a chrome browser access an arduino[^] via the local USB port.
More info on this feature of Chrome can be found... https://developer.chrome.com/apps/app_serial[^]
|
|
|
|
|
Hi all
Can we use java-script/JQuery for interfacing with Hardware device API installed on client system.
|
|
|
|
|
No. For security purposes browsers will not allow that. Use Java or ActiveX or some other technology that has to be installed on the client machine.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want to scrape a table from web page but the content of table doesn't exist in the source of page
the table created on the fly by java script
this is the source of page
<HTML>
<HEAD>
<TITLE>Cisco Unified Communications Manager Express GUI</TITLE>
<SCRIPT Language="JavaScript">
GUIVersion = "7.0.0.1 (Compatible with IOS 12.4(20)T)"
var MWinC
var newestDN = 0
var retryTimes = 0
var changeBit = false
var FeedString = new Array()
FeedString[0] = "Router config has been successfully changed."
FeedString[1] = "Configuration has been successfully changed."
FeedString[2] = "Configuration change failed."
FeedString[3] = "Other telnet session active. Write delayed."
var FailReason = new Array()
FailReason[0] = "Please report the following error: "
FailReason[1] = " Ambiguous Command."
FailReason[2] = " No Matched Command."
FailReason[3] = " No Matched Help Command."
FailReason[4] = " No Matched Alias Command."
FailReason[5] = " Config Locked Down Too Long."
FailReason[6] = " Configuration Change is not allowed."
FailReason[7] = " Wrong Tag Value."
FailReason[8] = " System is writing config to memory. Your change is aborted!"
FailReason[9] = " Parser return code failed."
FailReason[10] = " Invalid ITS command option."
var GenFeed = new Array()
GenFeed[0] = "Add the new extension to a new phone?"
function ksBanner() {
MWinC = "<html><head><style>BODY{\n margin-left: 0pt; \n margin-top: 0pt;\n}"
+ "</style><title>Cisco Unified Communications Manager Express</title></head>"
+ "<body><IMG src='logohome.gif' alt='Cisco Logo'>"
+ "</body></html>"
return MWinC
}
function Greet1() {
MWinC = "<html><head><title> View Window </title></head><style>BODY{BACKGROUND-COLOR: #cccccc} H2{PADDING-RIGHT: 0.25em; PADDING-LEFT: 0.25em; FONT-WEIGHT: bold; FONT-SIZE: 0.9em; PADDING-BOTTOM: 0.25em; MARGIN: 0.5em; COLOR: #666699; PADDING-TOP: 0.25em; FONT-FAMILY: Arial, Verdana, Lucida, sans-serif; BACKGROUND-COLOR: #cccccc }</style><body>\n"
+ "<H2>View Window</H2></body></html>\n"
return MWinC
}
function Greet2() {
MWinC = "<html><head><title> Change Window </title></head><body>\n"
+ "<h2>Change Window </h2></body></html>\n"
return MWinC
}
</SCRIPT>
</HEAD>
<FRAMESET rows="0,*" frameborder="0">
<FRAME name="banner" src="ITSMain" scrolling="NO" frameborder="0" marginwidth="0" marginheight="0" noresize>
<FRAME name="dispframe" src="javascript:parent.Greet1()">
</FRAMESET>
</HTML>
however i can get the content of the table from browser developer tools
any suggestions
|
|
|
|
|
You can try using AJAX.
Create an ajax call to a php file with the following code:
getPage.php
<?php
function getPost( $name, $default ){
$value = $default;
if( isset( $_POST[ $name ] ) && $_POST[ $name ] != '' ) {
$value = $_POST[ $name ];
}
return $value;
}
function getSslPage($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$site = getPost( 'site', '' );
$content = 'empty';
$error = '';
$content = getSslPage( $site );
if( !$content ) {
$error = 'no file found';
}
$arr = array( 'error' => $error, 'htmlResult' => htmlspecialchars($content) );
echo json_encode($arr);
?>
in javascript:
var data = {};
data["site"] = 'http://www.example.com/';
$.ajax({
type: "POST",
url: 'getPage.php',
data: data,
dataType: 'json',
success: function( msg )
{
if( msg['error'] !== '' ) {
alert( 'there was an error: ' + msg['error'] );
}
else {
alert( ' html Found: ' + msg['htmlResult'] );
}
}
});
|
|
|
|
|
How to validate postdate?
|
|
|
|
|
You have to be much more specific to get any answers - it's just not a question despite the question-mark...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
You can validate date with split the date into some part.
modified 9-Sep-14 7:49am.
|
|
|
|
|
what???Give some more clarity of what you ask buddy!.
|
|
|
|
|
I have a dropdown and multiple gridviews in the page .And on the basis of value selected from dropdown, data is loaded in Gridviews. And each gridview has linkbutton in each row, on click of which modal popup opens.
I want gridviews to be collapsed on dropdown select index change.
but my javascript function is not getting called.
And getElementByTagName('tr') is not working in internet explorer.
This is my Grid:
<asp:GridView ID="gvBillCalc" runat="server" AutoGenerateColumns="False" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="1px" CellPadding="3" Font-Bold="True" GridLines="Vertical"
Font-Size="Small" EmptyDataText="No Data Found" Width="100%" OnRowDataBound="gvBillCalc_OnRowDataBound"
BackColor="WhiteSmoke">
<Columns>
<asp:TemplateField>
<HeaderStyle Width="25px" />
<ItemStyle Width="25px" BackColor="White" />
<HeaderTemplate>
<asp:Image ID="imgTab" onclick="javascript:Toggle();" runat="server" ImageUrl="../Images/plus.gif"
ToolTip="Expand" />
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Item Particular">
<ItemTemplate>
<asp:Label ID="lbDesc" Text='<%#Eval("desc")%>' runat="server"></asp:Label>
<asp:HiddenField ID="hdnID" runat="server" Value='<%#Eval("id") %>' />
</ItemTemplate>
<HeaderStyle Font-Size="14px" />
<ItemStyle Font-Size="12px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount(In Rs.)">
<ItemTemplate>
<asp:Label ID="lbAmt" Text='<%#Eval("total")%>' runat="server"></asp:Label></ItemTemplate>
<HeaderStyle Font-Size="14px" />
<ItemStyle Font-Size="12px" HorizontalAlign="Right" />
</asp:TemplateField>
<asp:TemplateField HeaderText="View/Edit">
<ItemTemplate>
<asp:LinkButton ID="lbViewEdit" runat="server"></asp:LinkButton>
<asp:HiddenField ID="hdnViewEdit" runat="server" Value='<%#Eval("flag") %>' />
</ItemTemplate>
<HeaderStyle Font-Size="14px" />
<ItemStyle Font-Size="12px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Remarks">
<ItemTemplate>
<asp:Label ID="lbRemark" Text='<%#Eval("Remarks")%>' runat="server"></asp:Label></ItemTemplate>
<HeaderStyle Font-Size="14px" />
<ItemStyle Font-Size="12px" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<EmptyDataRowStyle BackColor="#FFC0C0" Font-Bold="True" Font-Size="X-Small" />
</asp:GridView>
This is my javascript:
var Grid = null;
var UpperBound = 0;
var LowerBound = 1;
var Grid1 = null;
var UpperBound1 = 0;
var LowerBound1 = 1;
var CollapseImage = '../Images/minus.gif';
var ExpandImage = '../Images/plus.gif';
var CollapseImage1 = '../Images/minus.gif';
var ExpandImage1 = '../Images/plus.gif';
var IsExpanded = true;
var IsExpanded1 = true;
var Rows = null;
var Rows1 = null;
var n = 1;
var n1 = 1;
var TimeSpan = 25;
var TimeSpan1 = 25;
window.onload = function () {
Grid = document.getElementById('<%= gvBillCalc.ClientID %>');
UpperBound = parseInt('<%= this.gvBillCalc.Rows.Count %>');
Rows = Grid.getElementsByTagName('tr');
}
function Toggle() {
debugger;
var Image = this;
ToggleImage(Image);
ToggleRows();
}
function ToggleImage(Image) {
if (IsExpanded) {
Image.src = ExpandImage;
Image.title = 'Expand';
Grid.rules = 'none';
n = LowerBound;
IsExpanded = false;
}
else {
Image.src = CollapseImage;
Image.title = 'Collapse';
Grid.rules = 'cols';
n = UpperBound;
IsExpanded = true;
}
}
function ToggleRows() {
if (n < LowerBound || n > UpperBound) return;
Rows[n].style.display = Rows[n].style.display == '' ? 'none' : '';
if (IsExpanded) n--; else n++;
setTimeout("ToggleRows()", TimeSpan);
}
This is Code Behind:
protected void ddlNodeName_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlNodeName.SelectedItem.Value != "0")
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "CallMyFunction", "Toggle();", true);
Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "Toggle()", true);
ClientScript.RegisterStartupScript(GetType(), "CallMyFunction", "Toggle();", true);
}
else
{
}
}
|
|
|
|
|
This[^] article has the sample on how you can use client side event. Also, it has sample on collapsing grid rows which might help you.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Can we do something with this forum software? When you switch between messages using the keyboard it would be nice to lock the message position. It would be pretty easy to add that functionality. Do you want me to do it?
Fever
|
|
|
|
|
Bugs or suggestions for the Code Project site should go in the Bugs and Suggestions[^] forum.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi
I am working on an existing project inherited from one of these fly by night digital media companies. They probably had some amazing deadline as usual that results in bad website construction.
The developer at the time thought it great to use RequireJS and load every script file used by the solution into the main aspx page. So when you open/launch the website you are presented with a login screen. If you investigate the login page there is a list of script files loaded even if you never get to the subsequent page that use one of these script files. The second problem is that RequireJS also (sometimes) times out and some scripts are not loaded properly.
The problem I have is the following:
I need to strip out the scripts that is not needed at login stage and only include these scripts when needed. This means: still using RequireJS load the common script files in the main aspx and then when navigating to content pages include/append the additional script files without losing the common ones.
How do I accomplish this? Is there a way to sub load scripts?
What I have tried:
- Use require("script1", "script2", "script3"); in main
- Then use require("script4a", "script4b"); to add additional scripts. But this approach removes the common scripts ("script1", "script2", "script3") and only loads ("script4a", "script4b"), and I have 2 references to require.js as well.
|
|
|
|
|
function VB_downloadXML()
dim xmldatawindow
set xmldatawindow = parent.frames(0)
xmldatawindow.User_Valid_GroupOptionsXMLDoc.async = false
xmldatawindow.User_Valid_GroupOptionsXMLDoc.load"User_valid_group_options_Generate_XML.asp"
xmldatawindow.Lookup_Parent_Link_URL="psb_menu.asp"
end function
which function in java script replace the instead of vb script , bec i am getting error in ie8 amd ie9 browser.(The value of the property 'VB_downloadXML' is null or undefined, not a Function object
)
|
|
|
|
|
Good Day all
i am reluctantly maintaining a Classic Asp application that will be re-written in few months to come. i have an issue where i have a Code like this
if(document.frmEntry.optMethod != "undefined")
{
if (document.frmEntry.optMethod.selectedIndex == 0) {
strPrompt=strPrompt+'Please specify the Valuation Method\n';
if ( objFocus == null ) {
objFocus = document.frmEntry.optMethod;
}
}
}
my problem here is that even if document.frmEntry.optMethod is not equal to "undefined" the code still go into the condition as if it was true. i have attached a proof in my debuger.
http://www.vetauinvest.com/Example/IE_DEBUGGER.png[^]
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
modified 3-Aug-14 15:47pm.
|
|
|
|
|
Try using a Falsy check.
The following values are always falsy:
false
0 (zero)
"" (empty string)
null
undefined
NaN (a special Number value meaning Not-a-Number!)
Your code should look like as follows:
if(!document.frmEntry.optMethod)
{
if (document.frmEntry.optMethod.selectedIndex == 0) {
strPrompt=strPrompt+'Please specify the Valuation Method\n';
if ( objFocus == null ) {
objFocus = document.frmEntry.optMethod;
}
}
}
|
|
|
|
|
You are very true about 'false' check, but sometimes it is a good practice to write full code and explicitly state against what are you want to check. It's of course only a matter of maintainability/readability...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
That should be undefined and NOT "undefined" !!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
The "undefined" shown in the debugger is not a string, so you can't compare it as one.
To really test if your value is undefined, you can use this:
if(typeof document.frmEntry.optMethod != 'undefined')
The typeof operator returns the type of the argument as a string.
|
|
|
|
|
I can't see why use undefined as string - with or without typeof!?
In JavaScript undefined is a value property of the global namespace and yous should use it according to it...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank you , this info is enough to solve the issue.
thanks again
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
The typeof for an undefined value is always "undefined". The value undefined being in the global namespace opens up some possible problems:
function madness() {
var a = 'fish', undefined = 'fish';
if(a === undefined) {
}
}
function mistake() {
var a = 'fish';
if(undefined = a) {
}
}
I know these are pretty unlikely scenarios, but better safe than sorry.
In earlier browsers "undefined" was not a testable value so expressions like (a == undefined) would produce the helpful message "undefined is undefined".
|
|
|
|