If I have a Browser and I call browser.loadURL("view-source:http://www.example.com); it goes straight to Chromium's source viewer. Is there a way to do the same thing with the loadHTML or loadData methods?
Or is there a way to programatically switch it to that view once the page has loaded?
The view-source URL prefix is a specific URI scheme that is handled by Chromium itself. Therefore, this prefix can be used with URLs only.
The general purpose of the loadHTML() and loadData() methods is to load and render the HTML string as a regular web page instead of displaying the source code in the browser. Therefore, there is no straightforward approach to make these methods display the source code instead of rendering the page.
However, you can consider saving the HTML to a temporary file and then load it as shown below:
browser.loadURL("view-source:file:///f:\\data\\contents.html");
Related
I notice that most GXT/GWT applications put the nocache.js file after the body tag. And few seem to put in the include in the header tag. Why is that?
Given the fact that the GWT script tag will be evaluated synchronously (the tag), but fetched asynchronously (the code, into an iframe), I don't see why not put it as the very first thing. Time saved!
Unless, you have some kind of complex logic that cannot have the chance to be properly displayed before the onModuleLoad() call (e.g., images evaluated but still not fetched), much like Steffen Schäfer pointed out. But you can defer you app startup for them though.
For more info, have a look here.
From my point of view there are 2 cases:
If you use GWT to only enhance your page that is generated on the server side then put the <script> at the end. That allows your browser to render the initial content of the page before parsing the JS code.
If you built a single page application that is completely generated by GWT on the client side, there's no content to be initially shown. In that case you can put the <script> to the head.
Be aware that 1. also applies if you implemented a loading animation or placeholder content to be initially shown.
I have a Java Web Project and I want to have a split test in my application. I want to be able to select different header images according to the passed query string. For instance, if the user retrieves the following url:
http://www.website.com/?header=1
Then I show the image A for the header. If the user retrieves the url like this:
http://www.website.com/?header=2
The I show the image B.
I'm already receiving the 'header' value in my html by expression language variable. The problem is that I set the image url in a CSS file. How can I pass this variable to the CSS file to load the correct image?
PS: I know I can apply the style in the HTML file, but I want to extract all of my styles in the CSS file.
That's not possible unless you use something like LESS.
What you could do is make separate CSS files, use the querystring to determine your needs with Java Web and load the one you need depending on the situation.
include 2 different classes for the different background header images in your css, then apply the different class in coding.
.header1 {
background-image: url(background1.jpg);
}
.header2 {
background-image: url(background2.jpg);
}
If I understood your question correctly, I believe you can do this by applying different CSS class to your header based on what input you gets from header.
You have three basic options:
Switch CSS files based on the query parameter, with one CSS file per header image - you can have these just set the header image, and have the static styles in their own file.
Use something like LESS or SASS.
Write your CSS as a JSP file or dynamically generated via servlet, and change the style dynamically on the server.
Divide your CSS styles into 3 parts:
common.css
header1.css
header2.css
Depending on your headers, you can include either of headerN.css classes. You can solve it also on server side (generating different includes in <head>) or on client side (use javascript to extract the header value and include the proper css dynamically)
I'm trying to make use of Vexflow (http://vexflow.com/) on the Android. However, I'm stumped as to the best way to display the output. Is it possible to have a series of webviews and then feed the javascript calls to them? Something like this is what I'm trying to achieve:
example image http://paraboxstudios.com/javascript_example.png
You can include an HTML file along with any JavaScript files in your assets or resources and then load it in a single WebView. The loadData method may be of particular interest (if you have problems, you can also try the loadDataWithBaseURL method which sometimes gets around some issues).
Using Java (.jsp or whatever) is there a way where I can send a request for this page:
http://www.mystore.com/store/shelf.jsp?category=mens#page=2
and have the Java code parse the URL and see the #page=2 and respond accordingly?
Basically, I'm looking for the Java code that allows me to access the characters following the hash tag.
The reason I'm doing this is that I want to load subsequent pages via AJAX (on my shelf) and then allow the user to copy and paste the URL and send it to a friend. Without the ability of Java being able to read the characters following the hash tag I'm uncertain as to how I would manipulate the URL with Javascript in a way that the server would be able to also read without causing the page to re-load.
I'm having trouble even figuring out how to access/see the entire URL (http://www.mystore.com/store/shelf.jsp?category=mens#page=2) from within my Java code...
You can't.
The fragment identifier is only used client side, so it isn't sent to the server.
You have to parse it out with JavaScript, and then run your Ajax routines.
If you are loading entire pages (and just leaving some navigation and branding behind) then it almost certainly isn't worth using Ajax for this in the first place. Regular links work better.
Why can't you use a URL like this:
http://www.mystore.com/store/shelf.jsp?category=mens&page=2
If you want the data to be stored in the url, it's gotta be in the query string.
AJAX is a very powerful tool so I am struggling with it :-).
Is there any way or API(in java) so that I can get the HTML code which is generated by AJAX?
Generally, AJAX make use of inner HTML code and hence this inner HTML code is missing when I look into the page source of a page.
e.g click here
Just see the section OTHER NEWS. The content is populated by AJAX. When I look into the page source the code is not there.
I need this HTML code through a java program. How can I get it?
To have a Java application use the content received via AJAX, you need to first find the URLs from where the content is getting called from. In case this it would be http://itm2083.com/get_wwo_content.php?featureGroupId=8355&featureDisplayLimit=1&sponsorName=vortalx&wwoDivCounter=5&domainUrlForWWo=http://item2083.com/&featureImgDisplay=FLAG_TRUE&featureGroupImageWidthLimit=200&featureGroupDefaultImageUrl1=http://wwo.itmftp.com/75x75.gif&featureGroupDefaultImageUrl2=http://wwo.itmftp.com/75x75.gif&featureGroupDefaultImageUrl3=http://wwo.itmftp.com/75x75.gif
The featureGroupId= parameter has 5 IDs: 8355, 8359, 8367, 8369, 8429. Use these to pull the content from the Other News box.
The featureDisplayLimit= parameter determines how much content is pulled from the server.
If you want the nice HTML as well, the Java app will have to recreate it, as the HTML rendered on the site is created by JavaScript code.