I want to build a sample application where you can preview HTML code.
For example:
<TabControl......>
<tabItem Header="HTML".....>
<!-
Here I type my HTML code ...
<html>
<body>
<p>********Some Text*******</p>
</body>
</html>
which would be saved in the database as it is.
->
</TabItem>
<tabItem Header="Preview".....>
<!-
On clicking this Tab the Preview of the
above HTML code (read from the database)
should be displayed.
->
</TabItem>
</TabControl>
How do I display the preview?
Embed the WebBrowser control on the preview tab and pass the HTML into it using the NavigateToString or NavigateToStream methods.
You can use the WebBrowser control but please do not use it - it is filled with memory leaks and does not dispose propoerly. I have spent lots of time looking for solutions to the problems it produces in production code to no avail.
A quick search on this site will show some of the "unsolved" issues becasue basically it is a wrapper for a COM object (hence unmanaged) version of Internet Explorer and while it seems to work beautifully for displaying an embedded page in WPF the problems far out weigh its appearance of simplicity.
What you can do is use the Microsoft HTML to XAML parser, add a flowdocument tag at the beginning and end of the string and push it into the FlowDocumentScrollViewer control.
You can Embed the WebBrowser Tools
Related
I am trying to show a preview of a HTML content with page size, margins, header-footer and watermark applied. I had a fair success with using jsPDF so that I can show the preview before it gets converted to PDF in a new tab.
Instead I would like to have a live preview kind of work. The following is the abstracted form of the requirement where I have to HTML editors and the content from each are combined and shown preview like this.
Any change applied can be previewed by pressing the "Refresh" button on top including the page settings.
Can anyone help me in pointing to some plugin with which I could achieve the same? ASP .Net and Angular are the environment and would be more than happy to respond to any clarifications raised.
I can work on developing this with help of a developer but both of us at present lack the know-how. Any pointers in suggested approach is enough.
Show the codes, so anyone can see what's wrong with the code and why the relations are not connected with the HTML live show pdf.
I am trying to create a scraper using vb6, my technique is to search the html page with get between 2 text function.
the function is tested and working correctly for all the sites, except a new site that I tried to use the same technique with it and failed.
The problem is the html is not showing the data, piece of the html as below:
<tr>
<td valign="top" nowrap="nowrap" class="label">Company Name:</td>
<td><span class="search-custom" id="synopsisDetailsOppNum"></span></td>
</tr>
the value should appear between the span tag above, but it's not appeared inside the HTML as above code.
The website is using javascript to manage the data.
I have tried also to use wait function, may the data appear with the HTML, but failed too.
Is there any solution to get the value, even with vb.net as I can update my code
that website is using JavaScript to add data to the webpage and such manipulation will not show up on the page source
The follwoing is quoted from JavaScript & jQuery: The Missing Manual by David Sawyer McFarland
One problem with using JavaScript to manipulate the DOM by adding,
changing, deleting, and rearranging HTML code is that it’s hard to
figure out what the HTML of a page looks like when JavaScript is
finished. For example, the View Source command available in every
browser only shows the web page file as it was downloaded from the web
server. In other words, you see the HTML before it was changed by
JavaScript, which can make it very hard to figure out if the
JavaScript you’re writing is really producing the HTML you’re after.
For example, if you could see what the HTML of your page looks like
after your JavaScript adds 10 error messages to a form page, or after
your JavaScript program creates an elaborate pop-up dialog box
complete with text and form fields, it would be a lot easier to see if
you’re ending up with the HTML you want. Fortunately, most major
browsers offer a set of developer tools that let you view the rendered
HTML—the HTML that the browser displays after JavaScript has done its
magic. Usually the tools appear as a pane at the bottom of the browser
window, below the web page. Different tabs let you access JavaScript
code, HTML, CSS, and other useful resources. The exact name of the tab
and method for turning on the tools panel varies from browser to
browser: • In Firefox, install the Firebug plug-in (discussed on page
477). Open a page with the JavaScript code you wish to see and open
Firebug (Tools→Firebug→Open Firebug). Click the HTML tab in the
Firebug panel, and you’ll see the complete DOM (including any HTML
generated by JavaScript). Alternatively, you can use the Web Developer
toolbar in Firefox to view
both the regular HTML source, and the generated HTML. • In IE 9, press
the F12 key to open the Developer Tools panel, then click the HTML tab
to see the page’s HTML. In the case of IE9, the HTML tab starts by
showing the downloaded HTML (the same as the View Source command). But
if you click the refresh icon (or press F5), the HTML tab shows the
rendered HTML complete with any JavaScript-created changes. • In
Chrome, select View→Developer→Developer Tools and click the Elements
tab in the panel at the bottom of the browser window. • In Safari,
make sure the Developer menu is on (choose Safari→Preferences, click
the Advanced button, and make sure the “Show Develop menu in menu bar”
is checked. Then open the page you’re interested in looking at, and
choose Develop→Show Web Inspector. Click the Elements tab in the panel
that appears at the bottom of the browser window. • In Opera, choose
Tools→Advanced→Opera Dragonfly. (Dragonfly is the name of Opera’s
built-in set of developer tools.) In the panel that appears at the
bottom of the browser window, click the Documents tab.
so the scraper won't download the page after the JavaScript finished it will get what it looks before any the JavaScript manipulation
you can watch Michael Schrenk talking about Screen Scraper Tricks: Extracting Data from Difficult Websites
http://www.youtube.com/watch?v=NtffxCi8aq4
I know you can't hide HTML / Javascript / CSS because it's run on the client side, but how does iCloud.com hide its HTML?
When I view the page source on iCloud.com I just get presented with loads of Javascript, but when I go to inspect element in Chrome I can see the HTML.
I was just curious as to how they did this.
If you look closer at the page source you'll see this:
#noscript div#container{position:absolute;top:0;left:0;right:0;bottom:0;min-height:500px;}
#noscript div#overlay{position:absolute;top:0;left:0;right:0;bottom:0;min-width:600px;min-height:550px;background:#0B080E;opacity:.84;}
#noscript div#container div.float-center-canvas{z-index:101;position:absolute;background-image:url
....
It seems all the markup is generated in javascript and if javascript isn't enabled they run noscript. Not that anyone would be able to use iCloud without JavaScript in the first place...
All that javascript you see when viewing the source is responsible for generating the document that you can then inspect in developer tools once the page is loaded. Nothing is hidden; it's just that the document doesn't get generated until after the page is loaded.
Hi im demonstrating the html tags that are new in CSS3 and I'm making a documentation for the easy viewing and interpretation on comparing both the source code and the output.And its its really hard for me going to the source code and then selecting the file and browsing it on the browser
It would be great if I could view both the source code and the output
on the same html page.
For example(I m talking from the page I ve attached below) if I select Source code the source code must be displayed on the screen or from any of the text editors.
I don't know whether it is possible to do so,If possible it would be great
if anyone of you could guide me.
To get the source of just one element, do this:
HTML: <div id="one"><span id="two"></span></div>
JS:
document.getElementById('one').innerHTML // returns <span id="two"></span>
document.getElementById('one').outerHTML // returns <div id="one"><span id="two"></span></div>
To get the source of the entire page, do this:
document.doctype + document.documentElement.outerHTML
document.doctype returns the doctype, and document.documentElement.outerHTML returns the code for the <html> tag and everything inside it.
Use the developer tools you have in all modern browsers (the most advanced ones being Chrome and Firefox).
You typically open such a toolset using the Ctrl-Uppercase-i shortcut.
Then you have a lot of useful tools, as described here for Chrome or here for Firefox.
One of them seems to be exactly what you need. For example in Chrome, the first tab, called "Elements", shows you the source code with a lot of goodies (interpreted css with reasons, element displayed when you hover the mouse, search, etc.).
I'd suggest you take the time to read the linked documentation, as this is an essential tool of any web developer. And you won't be able to stop using those tools as soon as you go deeper in javascript or css.
I am trying to create and internal hyperlink in wx.html.HtmlWindow using an anchor and href in my html content:
html_content="""Go To Results found
<a name="resultsfound"><h2><b>RESULTS FOUND</b></h2></a>"""
However, when I click on the hyperlink it tries to open the location in the browser on a new tab and does not go to the corresponding location in the page.
Do you know why? Any suggestions on how to solve it?
Thanks in advance,
Zvi
wx.html.HtmlWindow isn't a web browser widget. It is just for displaying HTML formatted text. You could catch the hyperlink click, download the HTML and then try to refresh the contents of the wx.html.HtmlWindow. Note however that wx.html.HtmlWindow only supports the barebone basics of HTML. It doesn't do CSS or javascript or any other fancy HTML tricks.
On the other hand, if you're on Windows, you can use the ActiveX Internet Explorer widget and do exactly what you want. Or you can try the wx Webkit widget that's not included with wxPython and is in beta.