import wixLocation from 'wix-location';
export function button4_click(event) {
//Add your code for this event here:
$w("#box1").hide();
$w("#horizontalMenu1").show();
$w("#socialBar1").show();
$w.onReady(function () {
setTimeout(() => {
wixLocation.to("/about");
}, 2000); // set in milliseconds //
});
}
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
![feature fixed.png](https://static.wixstatic.com/media/3bfa8a_f845e1016b8a49758acdd6edd6610c3b~mv2.png/v1/crop/x_0,y_2,w_852,h_508/fill/w_104,h_62,al_c,q_85,usm_0.66_1.00_0.01,blur_3,enc_auto/feature%20fixed.png)
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Thank you all for your help. Its working the way I want on both mobile and desktop. Here is the final code in case anyone else has the same problem.
import wixLocation from 'wix-location'; import wixWindow from 'wix-window'; export function button4_click(event) { //Code for desktop if(wixWindow.formFactor === "Desktop"){ $w("#box1").hide(); $w("#horizontalMenu1").show(); $w("#socialBar1").show(); } //Code for non-desktop if(wixWindow.formFactor === "Mobile" || wixWindow.formFactor === "Tablet"){ $w("#box1").hide(); $w("#cart1").show(); $w("#menuToggle1").show(); } //Code for timer function and move onto next page $w.onReady(function () { setTimeout(() => { wixLocation.to("/about"); }, 1700); // set in milliseconds // }); }
Use this:
if(wixWindow.formFactor === "Mobile" || wixWindow.formFactor === "Tablet") { $w("#button4").onClick(event => { } }
You cannot use export functions inside of "if".
I need the code to work on both desktop and mobile. Yet i can only export function button4_click(event) once
See this page here.
https://support.wix.com/en/article/corvid-tutorial-redirecting-mobile-visitors
Also, these pages for mobile only code.
https://support.wix.com/en/article/corvid-writing-code-that-only-runs-on-mobile-devices
https://support.wix.com/en/article/corvid-tutorial-displaying-elements-in-mobile-only
I know that i need to add the following line under the other import
import wixWindow from 'wix-window';
which I have. I also know that I need to add this line somewhere
if(wixWindow.formFactor === "Mobile" || wixWindow.formFactor === "Tablet")