How to open two Pages - javascript

I use the following splitview for my mobile application.
asyraf splitview
For example my first left content in the tablet view is a button. when I click the button it loads a new page with a second button and a back button to the first page. When I click on the second button it loads a right content.
When I click the back button it loads the first page left content but the right content is the same.
How can I on click the back button load a new left content and a new right content at the same time?
Attention: The right content call need a href="rightPage" and data-panel="main"

Attach the following to the button's click() event:
location.hash = "pagehash";

Related

JQuery click() does not load page properly if page has not been loaded via navbar first

I am working with this Template from templatemo.
I wanted to include some references to other parts of the website in the body text (e.g. Please "contact me" for further information). If you click "contact me" the page should navigate to "Contact" in the same manner as if the user clicked on the navigation bar to navigate to the page (with the same animation).
In order to so, i added the following code to trigger a click event:
<p class="tm-text">Contact me via the <a id="myLink" href="javascript:loadPage(5);">contact form</a></p>
And the function to trigger the click:
function loadPage(pageNo) {
$(document).ready(function() {
$('.nav-item').get(pageNo).click();});
}
So this code is working, if I click on the reference the page changes as if I clicked the navigation bar. BUT:
If I reload the page and click on the reference, the page navigates to the contact page, which then however is not diplayed properly (the contact form and the google maps view are missing).
If I reload the page, first open the contact page via the menu, then switch to the page with the reference and click on it, the contact page is loaded properly.
This behaviour is also shown if I reference another page (e.g. the Gallery). The gallery elements are displayed (the page is not completely empty), but the spacing between the elements is not correct.
It seems like every page has to be loaded at least once via the navigation bar. If this has happened, all pages are displayed properly when opened via a reference in the text.
Thanks for your support.
Your template use Hero slider + some customs JavaScript functions to move between "pages", so you need to use the same functions to get the same behaviour.
Doing that will work:
<p class="tm-text">Contact me via the <a id="myLink" href="javascript:goToPage('Contact');">contact form</a></p>
You need to add this JS function:
function goToPage(page_name) {
// Retrieve the <a> tag with the page_name
// page_name is the string of the page in the navbar
page_link_a = $('.navbar-nav .nav-link').filter(function(index) { return $(this).text() === page_name; });
page_link_li = page_link_a.parent();
// Trigger js code from hero slider
page_link_li.click();
// Trigger js code from templatemo
page_link_a.click();
}
The function goToPage() take one parameter, the string name of the section so if you have a section named My Gallery you need to put that, not my-gallery nor an index.

How to scroll a modal box in Selenium Python?

When I click on a link to accept Terms and conditions, a modal box pops up.
I need to scroll the modal pop up down, enable the Accept button and then click Accept.
I'm not able to scroll the modal box.
I tried:
context.driver.execute_script("arguments[0].scrollIntoView(true);", ars)
Where ars is the last element in the popup. This shows the last element ars in the modal without scrolling down.
I also tried:
actions = ActionChains(context.driver)
actions.move_to_element(ars)
This has the same behaviour: shows the last element ars in the modal without scrolling down.
Any other methods to scroll down are highly appreciated.
TIA
First try to find the new iframe which contains the name of the modal box.
modal_box = driver.find_element_by_xpath('/html/body/div[2]/div.....')
driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", modal_box)
Make sure its scrolling for the entire height. Then try to find the visibility of the accept button

addthis share button not working when I open the modal twice

I'm using addthis share button in my website, but the click of the button is in a modal that is loaded dynamically, so when the modal html is loaded, I call the script of addthis this way:
var addthisScript = document.createElement('script');
addthisScript.id = 'addthisscript';
addthisScript.setAttribute('src',
'//s7.addthis.com/js/300/addthis_widget.js#domready=1')
document.body.appendChild(addthisScript);
So, when I open the modal at first time, it works!
But, if I close the modal and open again and click the button to share again, it just reload the page.
After reloaded the page, starts to work again, but just once.
I already try remove the script from DOM and create again, but still doesn't work!!
When the modal is closed, I remove the entire HTML, this way:
$(`#${id_modal}`).on("hidden.bs.modal",() => {
$(`#${id_modal}`).remove();
}
And every time that I open the modal, I call the function addthis() that create the script above.
Any help?

C# code behind not working after load() jQuery

I have an update panel in aspx page.
Click on one of the button show a div from code behind, and load to that div element from another page
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(UpdatePanel), Guid.NewGuid().ToString(),
"UpsalePopup(); $('#MyDiv').load('PopUp/UpsaleAdv.aspx #UpsaleAdvPanel');"
, true);
And its working perfect.
After user close that div (have only picture)
click on asp Button to do function on server side, go to '/UpsaleAdv.aspx' and show it as 404.
Is the load() function ruin my page ? how can I prevent it or solve it ?
The page 'PopUp/UpsaleAdv.aspx' was an aspx page with <form> tag.
And after do this function:
$('#MyDiv').load('PopUp/UpsaleAdv.aspx #UpsaleAdvPanel');"
it makes the current page (myaspa.aspx) to get the funcunality from PopUp/UpsaleAdv.aspx
And once I removed the <form> tag and replaced the page to inherit from master page all works perfect.

jquery content accordion menu, issue with content bouncing open when trying to close

I have made a form and if you click on the Info image it drops down with more information, however if i click on the image to close. It with close but then bounce back open.
If I click just next to the image it will close properly.
Any ideas why this happens?
link:
http://www.vestedutility.com.au/home_safety_check.php
Change the line from your code:
if(jQuery(e.target).is('.active')) {
To
if(jQuery(this).is('.active')) {

Categories