1

I have a page with several different iframes which are delaying my loading time so I'd like them to load only when I click on a separate button.

As I have it set up now, there are "window blocks" and inside each one of these divs there are two siblings, the "app link" and the app "window";

so here's my structure (there are several similar "window blocks" on the same page)

<div class="w-clearfix window-block">
<a class="app-link w-inline-block" data-ix="open-window" href="#" style="transition: all 0.2s ease-in-out 0s;">
<div class="w-clearfix wapps window ui-draggable" data-ix="collapse-on-load" style="transition: color 0.2s ease-in-out 0s, background-color 0.2s ease-in-out 0s; opacity: 0; transform: translateX(0px) translateY(100%) translateZ(6000px); display: none;">

I'm also using a little jquery to make the windows draggable (it's a very similar situation to a Windows (or MacOS) desktop: shortcuts and windows.

$( function() {
    $( ".window" ).draggable({ handle: ".window-handle" });  
} ); 

Is it possible to make each sibling window load as I click on the button next to it with a single "line" of code? Or do I have to add one for each class / element? What's that line of code? (I'm sorry if this sounds dumb..)

Is it possible to also unload that div on a second click and then reload again when the button is clicked (for a third time)?

I'm also trying to make each window jump to the top of the screen (move up on Z?) as I click on each window but that's not working, any suggestions?

Thank you very much...

6
  • You mean you want to load a iframe into a div when a button is clicked? I dont see a button in your code. Commented Sep 19, 2016 at 11:27
  • First line talks about iframe and the html has div - which is it? Commented Sep 19, 2016 at 11:28
  • hey, sorry for that, what I would really need is to load a whole div (and its content and iframe) only on click; in this case the "app link" is the button and "w apps" is the window. Commented Sep 19, 2016 at 11:30
  • Possible duplicate of jQuery: Loading iframe on click - how to write manageable code? Commented Sep 19, 2016 at 11:30
  • You could create the iframes with empty src values, and then use a button to trigger a function like document.GetElementById('IframeID').src="link" to actually load the iframe. Unfortunately, you'd have to do that for each frame separately. Commented Sep 19, 2016 at 11:31

1 Answer 1

0

I think what you need is AJAX. A button click sends a request to the server and writes the response HTML into the window. The W3Schools tutorial is pretty straightforward.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.