<div id="main">
<style type="text/css">
</style>
<script language="JavaScript">
</script>
<p style="margin: 0pt 0pt 0.5em;"><b>Media from <a onclick="(new Image()).src='/rg/find-media-title/media_strip/images/b.gif?link=/title/tt0087538/';" href="/title/tt0087538/">The Karate Kid</a> (1984)</b></p>
<style type="text/css">
</style>
<table style="border-collapse: collapse;">
</table>
</div>
I need to somehow extract the href value of the (new Image()). How exactly would I accomplish this with HtmlAgilityPack?
I'm new to it, and so far I haven't found a useful tutorial on how to effectively use it for parsing.
Thanks for the help!
HtmlAgilityPack by itself does not provide many parsing options. But you can use it with XPath to get any sort of complex parsing done. In your example you could do -
var testString = "..."; // Your html
var doc = new HtmlDocument();
doc.LoadHtml(testString);
var node = doc.DocumentNode.SelectSingleNode("/div/p/b/a");
var hrefValue = node.GetAttributeValue("href", ""));
This will give
/title/tt0087538/
Related
I build an iphone app using phonegap. I am using sqlite3 db to store the data locally. The app is working perfectly on simulator but gives error on actual ios device. It is throwing "Could not prepare statement (1 no such table: table_name)" error code for the same is Code=5.
Do i have to install sqlite plugin on ios device? The app is in a testing stage. I followed steps provided in this, to install the app on ios device.
What am I missing here?
Update:
This is the piece of code I'am using. My db resides at location
/Users/imac/Library/Application Support/iPhone
Simulator/7.0.3/Applications/4C7CC11A-8938-479F-B810-86121D3311B7/Library/WebKit/Local Storage/File_0
And on the device it resides at
AppData/Library/WebKit/Local Storage/File_0
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<title>Books | Categories</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">
var db;
var shortName = 'Books';
var version = '1.0';
var displayName = 'BooksDB';
var maxSize = 200000;
function errorHandler(transaction, error) {
alert('Error: ' + error.message + ' code: ' + error.code);
}
function successCallBack() {
alert("DEBUGGING: success");
}
function nullHandler(){
alert('null handler');
};
function onBodyLoad(){
if (!window.openDatabase) {
alert('Databases are not supported in this browser.');
return;
}
db = window.openDatabase(shortName, version, displayName, maxSize);
alert('db open');
ListDBValues();
}
function ListDBValues() {
var ArrayAlphabet=new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
$('.container').empty();
for (var i = 0; i < ArrayAlphabet.length; i++) {
data='<div class="order" id="'+ArrayAlphabet[i]+'"></div>';
load_books(ArrayAlphabet[i]);
$('.container').append(data);
data="";
}
return;
}
function load_books(bookTitleAlphabet)
{
if (!window.openDatabase) {
alert('Databases are not supported in this browser.');
return;
}
db.transaction(function(transaction) {
transaction.executeSql('SELECT * FROM books where book_title like "'+bookTitleAlphabet+'%" order by book_title desc;', [],
function(transaction, result) {if (result != null && result.rows != null) {
$('#'+bookTitleAlphabet).html(bookTitleAlphabet);
for (var i = 0; i < result.rows.length; i++) {
var data;
var row = result.rows.item(i);
data="<a href='details.html?id="+row.book_id+"'> <div class='book'>";
data +="<div class='book_img'><img src="+row.book_thumb_location+"></div>";
data +="<div class='book_detail'>";
data +="<div class='title'>"+row.book_title+"</div>";
data +="<div class='author'>"+row.book_author+"</div>";
data +="</div>";
data +="<div class='clear'>";
data +="</div>";
data +="</div>";
data +="</a>";
var tempId='#'+bookTitleAlphabet;
$(tempId).append(data);
tempId="";
}}
if (result.rows.length==0)
{
var tempId='#'+bookTitleAlphabet;
$(tempId).hide();
}
},errorHandler);},errorHandler,nullHandler);
return;
}
</script>
</head>
<body onload="onBodyLoad()">
<div id="wrapper">
<div class="overflow_hide">
</div>
<div class="menu">
<div class="header">
<div class="back">
<a href="index.html">
<input class="gobutton" type="button" value="Back" ></a>
</div>
<div class="list_book">BOOKS
</div>
<div class="settings">
<a href="index.html">
<input class="gobutton" type="button" value="Home" ></a>
</div>
</div>
<div class="container">
<div class="clear">
</div>
</div>
</div>
<div class="opac">
<a href="about.html">
<div class="opac1">About Us
</div></a>
<a href="search.html">
<div class="opac1">Search
</div></a>
</div>
<div class="clear">
</div>
</div>
</body>
</html>
Is this because the app cannot find the db?
EDITED/NEW ANSWER:
As the article here points out, you will likely have to do some work in XCode itself. As you correctly noted, the pathing to the database is different for pre-populated versus runtime-created databases. In short, your modifications will look for the pre-populated database and move it to the expected location/folder when it is detected. The nice thing: this will happen before your code begins to execute (javascript) so your existing code won't be "aware" that this even happened.
It is worth noting that the post I am referring you to goes past this and excludes the item from backup to iCloud. You will have to make a judgment call on whether you want to do that or not. It is pre-populated does not mean you wish to NOT back up that database nor does it make the leap (as the author does) that the pre-populated database is likely "large".
OLD ANSWER:
The error does not seem to indicate that it is having difficulty with SQLite itself, but a problem with a specific table not existing.
This typically happens when you are testing (via simulator) and at some point hit the appropriate code that performs the CREATE statement for the table. Then, later on, you get accustomed to that table being there and accidentally disconnect the schema-checking or table-existance-checking code. Since the table exists already, your simulator continues on about and never tries to re-create that table. When you go to run it on the actual device, however, that CREATE code never executes and falls into an area where you expect the table to exist - which causes the error.
Since you haven't posted any code, this is all conjecture on my part. If you want me to take a look, I would be happy to.
I've used the solution here http://jsfiddle.net/KADqA/23/ to add an image to a jquery mobile checkbox, and it works fine, but now the label text is out of alignment with the checkbox images (too high) and I can't figure out how to center it with css.
Here's a portion of the code to generate the html
<input type=checkbox id=chk" + ingindex + " class='chk chk" + ingindex + "' name=chk" + ingindex + "><label for=chk" + ingindex + ">" + item + "<a href='#' data-rel='dialog' ><img class=recimg src='http://webrecipemanager.com/images/recipe/" + image + "' alt='" + name + "'></a></label>
This is the generated html from firebug
<div id="div0" class="drag inaisle ui-draggable" name="div0">draggable=Object {
element={...}, options={...}, started=
false
, more...}jQuery16405345229560181788=Object { events={...}, handle=function()}
<div class="ui-checkbox">
<input id="chk0" class="chk chk0" type="checkbox" name="chk0">checkboxradio=Object { element={...}, options={...}, label={...}, more...}jQuery16405345229560181788=Object { events={...}, handle=function()}virtualMouseBindings=Object { vmousedown=
true
, vclick=
true
}
<label class="ui-btn ui-btn-corner-all ui-btn-icon-left ui-checkbox-off ui-btn-up-i" for="chk0" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="checkbox-off" data-theme="i">corners=
true
shadow=
false
iconshadow=
true
wrapperEls=
"span"
icon=
"checkbox-off"
theme=
"i"
buttonElements=Object { bcls=
"ui-btn ui-btn-up-i ui-b...er-all ui-btn-icon-left"
, outer=label.ui-btn, inner=span.ui-btn-inner, more...}jQuery16405345229560181788=Object { events={...}, handle=function()}virtualMouseBindings=Object { vmouseover=
true
, vclick=
true
}
</div>
<input id="item0" type="hidden" value="1/2 c Baking Cocoa" name="item0">
<input id="ing0" type="hidden" value="Baking Cocoa" name="ing0">
</div>
you can use Firebug or another developer tool to examine the CSS to manipulate...
see the docu
Overriding themes
The themes are meant as a solid starting point, but are meant to be
customized. Since everything is controlled by CSS, it's easy to use a
web inspector tool to identify the style properties you want to
modify. The set of of theme classes (global) and semantic structural
classes (widget-specific) added to elements provide a rich set of
possible selectors against which to target style overrides. We
recommend adding an external stylesheet to the head, placed after the
structure and theme stylesheet references, that contain all your style
overrides. This allows you to easily update to newer versions of the
library because overrides are kept separate from the library code.
In your case add the following
<style>
.ui-mobile a img, .ui-mobile fieldset {
vertical-align: middle;
}
</style>
see modified jsfiddle and the complete code of the working example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<style>
.ui-mobile a img, .ui-mobile fieldset {
vertical-align: middle;
}
</style>
</head>
<body>
<div data-role="page" id="home">
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" class="cbox" name="OptIn" id="OptIn"/>
<label for="OptIn">Receive E-mails From Us</label>
<input type="checkbox" value="1" class="cbox" name="tandc" id="tandc"/>
<label for="tandc">I agree to the <a href="#tc" data-rel="dialog" ><img src="http://dummyimages.com/25x25" /></a></label>
</fieldset>
</div>
</div>
<div data-role="page" id="tc">
<div data-role="header">
<h1>T and C</h1>
</div>
Read me
</div>
<script>
$('.ui-btn-text').click(function(event) {
var checked = $("#tandc[type='checkbox']").is(":checked");
var $this = $(this);
if($this.children('a').length) {
$.mobile.changePage('#tc', {
transition : 'pop',
role : 'dialog'
});
}
stateOfCheckbox(checked);
});
function stateOfCheckbox(checked) {
$('#home').live( 'pagebeforeshow',function(event){
$("#tandc[type='checkbox']").attr("checked",checked).checkboxradio("refresh");
});
}
</script>
</body>
</html>
screenshot:
I am working on a website and the owner of the website found three broken links (through a software/tool of IBM) in the given page. I removed two broken links but there is one broken link left. I searched the whole web page but I am unable to find it.
What can I do to find that link?
Here is the code of the page:
<?php
session_start();
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Legal Aid Service Monitoring System</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery3.js"></script>
<script type="text/javascript" src="js/jquery4.js"></script>
<script type="text/javascript" src="js/jquery5.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#login-form").validate({
debug: false,
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "Please enter a valid email.",
},
});
});
</script>
<style type="text/css">
label.error { width: 250px; color: red;}
</style>
</head>
<body>
<?php
if($_POST['login'])
{
require_once("config.php");
if($_POST['user_type']=='admin')
{
$user=mysql_real_escape_string($_POST['uname']);
$password=md5($_POST['pwd']);
$sql=mysql_query("select id from admin where username='$user' and password='$password'");
$count=mysql_num_rows($sql);
if($count>0)
{
$row=mysql_fetch_array($sql);
$_SESSION['admin']=$row['id'];
$date=date('d-m-y');
$time_now=mktime(date('h')+0,date('i')+00,date('s'));
$time=date('h:i:s',$time_now);
$login=mysql_query("insert into user_login (user_id, login_date, login_time) values ('$_SESSION[admin]', '$date', '$time')");
header('location: administrator');
}
else
{
?>
<script type="text/javascript"> alert('Incorrect Username and Password.');</script>
<?php
}
}
else if($_POST['user_type']=='advo')
{
$user=mysql_real_escape_string($_POST['uname']);
$password=md5($_POST['pwd']);
$sql=mysql_query("select id, status from advocates where email='$user' and password='$password'");
$count=mysql_num_rows($sql);
$row=mysql_fetch_array($sql);
if($count>0 and $row['status']=='1')
{
$_SESSION['advocate']=$row['id'];
$date=date('d-m-y');
$time_now=mktime(date('h')+0,date('i')+00,date('s'));
$time=date('h:i:s',$time_now);
$login=mysql_query("insert into advo_login (advo_id, login_date, login_time) values ('$_SESSION[advocate]', '$date', '$time')");
header('location: advocate');
}
else
{
if($row['status']=='0')
{
?>
<script type="text/javascript">alert('Your account has been blocked by admin.');</script>
<?php
}
else
{
?>
<script type="text/javascript">alert('Incorrect Username and Password.');</script>
<?php
}
}
}
}
?>
<div class="main" id="main">
<div id="headerbg">
<div id="header"></div>
</div>
<div id="center">
<div class="style1" id="centerright">
<div id="centerup">
<table width="514" border="0" align="center">
<tr>
<td><h3>Welcome to Legal Aid Service Monitoring System</h3></td>
</tr>
</table>
</div>
<div id="centerdown">
<div id="loginbg">
<form id="login-form" name="login-form" method="post" action="">
<table width="500" border="0" >
<tr><td></td>
<td height="30">
<input type="radio" name="user_type" value="advo" checked="checked" />Advocate
<input type="radio" name="user_type" value="admin" />Administrator
</td>
</tr>
<tr>
<td width="50"><span class="style5">Username:</span></td>
<td width="236"><label>
<input type="text" name="uname" class="required input" size="30" />
</label></td>
</tr>
<tr>
<td><span class="style5">Password:</span></td>
<td><label>
<input type="password" name="pwd" id="pwd" class="required input" size="30"/>
</label></td>
</tr>
<tr>
<td></td>
<td><label>
<input type="submit" class="style1loginbg" name="login" id="button" value="Login" />
</label></td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If you have Firebug or somekind of similar console access you could run this snippet of code on a page by page basis:
jQuery(function(){
var getHost = function(url){
url = String(url);
if ( (url.substr(0,5) == 'http:') || (url.substr(0,6) == 'https:') ) {
return url.split('/').slice(0,3).join('/');
}
else {
return null;
}
}
var host = getHost(window.location);
jQuery('a').each(function(){
var link = $(this), href = link.attr('href'), hst = getHost(href);
if ( hst === host || hst === null ){
jQuery.ajax({
url: href,
error: function(){
link.css('border', '5px solid red');
}
});
}
else {
link.css('border', '5px solid purple');
window.open( link,'_blank');
}
});
});
It should highlight with a red border any internal links that fail to load via ajax, and highlight any external links with purple (at which point it'll try and open the external link in a new tab for you to visually check). Obviously this might go a bit mad if your page has many external links...
It would be far better to actually get some link checking software - search Google - and run that... as that should act in a way that's know as 'Spidering a site'. Basically it would step through each of your pages and return a report of all the broken links found (you'd have to make sure the software supported cookies seeing as the site you've given requires authorisation).
One further thing to be aware of is that it isn't just links that can cause software to fire a 'broken link' error. You may find that some of your page resources trigger a 404... i.e. you should check all your images, css and js to make sure they load.
This suggestion doesn't solve the question, but I believe it's worth mentioning that the WebDev toolbar (http://chrispederick.com/work/web-developer/ (a firefox add-on) can at least help here.
It can display all links in a webpage and highlight and show all anchors. This can help the developer to 'scan' a website for out-of-place links. )
When installed, choose INFORMATION ยป and either
Display anchors
Display page information
Display link information
You can use a tool like phantomjs or protractor for this. One working tool can be found on https://github.com/ashittheone/broken-links-log.
this repository can be used to log all broken links upto 5 depth of anywebsite.
Although in a later version the depth is expected to be coming customizable
I would like to create some resizeable and draggable div tags contain textarea tags with jQueryUI.And I also want to use nicEdit to format text inside these textarea tags.But i can't combine them,maybe.I can't edit text if i use $(element).resizeable().draggable().Here is my code:
<html>
<head>
<title>Trouble using jquery ui resizeable, draggable and nicEdit</title>
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css" />
<script src="nicEdit/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery-ui-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var btnlist=['fontSize','fontFamily',
'bold','italic','underline','strikeThrough',
'left','center','right','justify',
'ol','ul','hr',
'indent','outdent',
'forecolor','bgcolor',
'subscript','superscript','removeformat'];
var myNicEditor = new nicEditor({iconsPath : 'nicEdit/nicEditorIcons.gif',buttonList :btnlist });
myNicEditor.setPanel('myNicEdit');
function ID()
{
var id="id";
var random_number=Math.round(Math.random()*1000000);
id+=random_number;
return id;
}
$('#a').click(function(){
var id=ID();
$('#content').append('<div class="d" style="width: 100px;height:100px;"><textarea style="width:100%;height: 100%" id='+id+'></textarea></div>');
myNicEditor.addInstance(id);
jQuery('.d').draggable().resizable();//If i remove this line,it work ok.
});
});
</script>
</head>
<body>
<div>
<button id="a">Add</button>
<div id="myNicEdit" style="width: 200px;" ></div>
<br />
<div id="content">
</div>
Can anyone give some solutions for me!Thank a lot!
</div>
You need to add 'handle' option when you apply draggable, so that it doesn't highjack the onmousedown event on all the child elements.
I'm doing rel="external" on the link that opens this page, so the DOM reloads which should rule out a lot of problems.
Nevertheless, with the following code I get a huge red background with a nice header and footer-- the map just doesn't initialize despite that the function is being called. Can anyone spot the problem? This bug has been holding me up forever; I've tried a million things including redesigning it as a multipage template without rel="external", but that didn't work either.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css"/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript">
$(function(){initializeMap(42,-73);});
function initializeMap(lat,lng) {
var latlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var crosshairLayer = new google.maps.KmlLayer('http://freezoo.alwaysdata.net/justcrosshair2.kml',
{preserveViewport: true});
crosshairLayer.setMap(map);
google.maps.event.trigger(map, 'resize');
map.setZoom( map.getZoom() );
}
</script>
</head>
<body>
<div data-role="page" data-theme="e" data-add-back-btn="true" class="map1" id="testing">
<div data-role="header"><h1>Map Page</h1></div>
<div id="content" style="position:absolute; bottom:40px; top:40px; left:0px; right:0px; background:green;">
<div id="map_canvas" style="position:absolute; top:0px; bottom:0px; width:100%; background:red;"></div>
</div>
<div data-role="footer" style="position:absolute; bottom:0px; width:100%;">
<h1>Working!</h1>
</div>
</div>
</body>
</html>
Your code doesn't load the google maps script. Like this for example:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>