PDA

View Full Version : JavaScript - lightwindow issue with iframe



MileMijatovic
11-24-2016, 11:01 AM
I trying for several days to solve issue with displaying iframe, I found http://www.dynamicdrive.com/forums/showthread.php?59121-Lightwindow-from-Javascript-call-party-on topic on your forum, something like this and I need to do, but I failed. Please help me how to fix issue

I will explain in details...

Links in xml looks like this

<Diretktreduktion_02>
<![CDATA[http://www.site.com/steel_agg_dr_article_en.html]]>
</Diretktreduktion_02>
.......

First I parsed links from xml to html,


<script type="text/javascript">
jQuery(function ($) {
$.ajax({
type: "GET",
url: 'steel_en_process.xml',
dataType: "xml",
success: loadDiagramData
});
function loadDiagramData(xml) {

$(xml).find("aggregate_links").each(function() {
var pfannen = $(this).find('Pfannenbehandlung_05').text();
var elektro = $(this).find('Elektrolichtbogenofen_04').text();
var brammen = $(this).find('Brammen_Strangguss_07_01').text();
var pfannen_1 = $(this).find('Pfannenbehandlung_05_01').text();
var direkt = $(this).find('Diretktreduktion_02').text();
var torpedo = $(this).find('Torpedopfanne_09').text();
var hochofen = $(this).find('hochofen_01').text();
var brammen_1 = $(this).find('Brammen_Strangguss_07').text();
var vakuum = $(this).find('vakuumbehandlung_06').text();
var sauers = $(this).find('Sauerstoffkonverter_03').text();



Then, I want to assign in an appropriate <div> and on click, link should get additional value "view=asIframe" and iframe should be displayed like this - http://prnt.sc/d9kbz3


Event.observe(window, 'load', function() {
var overlayElements = $$('#content_items a.background-color--black');

for(i=0; i<overlayElements.size(); i++) {
overlayElements[i].observe('click', function(event) {
openOverlayPopup(this.href);
event.stop();
});
}
});function openOverlayPopup(url) {
contentUrl = url+"?view=asIframe";
/* Fix the height of the overlay */
myLightWindow._getPageDimensions();
document.getElementById("lightwindow_overlay").setStyle({ height: myLightWindow.pageDimensions.height + 'px'});
myLightWindow.activateWindow({
href: contentUrl,
title: '',
height: 560,
width: 540,
type: 'external'
});
}

MileMijatovic
11-24-2016, 03:41 PM
Ok, I did something, but what is happening now...


Event.observe(window, 'load', function() {
var overlayElements = $$('.lightwindow');

for(i=0; i<overlayElements.size(); i++) {
overlayElements[i].observe('click', function(event) {
openOverlayPopup(this.href);
event.stop();
});
};
});
function openOverlayPopup(url) {
contentUrl = url+"?view=asIframe";
/* Fix the height of the overlay */
myLightWindow.activateWindow({
href: contentUrl,
title: '',
height: 560,
width: 540,
type: 'external'
});
};

With this code, onclick I managed to add view=asIframe at the end of link, but the frame does not get dimensions (height 560px and width 540px) and set it as params, but has dimensions width 100% and height 100%, which causes the iframe is a very very huge. Can you help me how to fix ?