Jump to content

W3schools Xml Tutorial: A Simple Cd Catalog Application.


mrallaire
 Share

Recommended Posts

This is in reference to the Xml Tutorial: A simple CD catalog application found at: http://www.w3schools.com/xml/tryit.asp?filename=tryxml_appI'm new to Xml and Javascrpt. I love this Xml Tutorial and have adapted it for my personal recipies. When you click on a table row, the full album information pops up. How can I make this pop up in a new window?I've tried target="_blank" and window.open and still can't get it to work.

Link to comment
Share on other sites

Look for this line:

document.getElementById("show").innerHTML=txt;

Erase it and add this in its place:

var W = window.open();W.document.open();W.document.write(txt);W.document.close();

Link to comment
Share on other sites

Ingolme's solution works like a charm. I see a number of open() features that control the status bar, window size, etc., but how can one open a window with css external style sheet formatting?
You use document.write() to write a <link> tag in the head of the document.
var W = window.open();W.document.open();W.document.write('<html>','<head>','<title>Page title</title>','<link rel="stylesheet" type="text/css" href="style.css">','</head>','<body>',txt,'</body></html>');W.document.close();

Link to comment
Share on other sites

Thanks again, the new code works like a charm. I'm still just a beginner with Java Script. I've gone through several tutorials now, but I still can't get my mind around the fact that one can place any html code with document.write();
It's preferrable to only use document.write() on an empty window, and not in the main window. If you want to change the HTML in the current document, you should modify the innerHTML property of an element.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...